+ Start a Discussion
Raghavi shivaramRaghavi shivaram 

opentab() I need to open my record (from search) in dynamic tab in the same page - Help needed

Hello ,

i need to open the record in dymanic tab in community. currently no click action is bein performed

code:

cmp:

    <aura:handler label="Open Tab" name="oSelectedRecordEvent" event="c:selectedsObjectRecordEvent" action="{!c.handleComponentEvent} " />


controller:

        
handleComponentEvent: function(component, event, helper) {
      var navEvt = $A.get("e.force:navigateToSObject");
        var workspaceAPI = component.find("workspace");
        workspaceAPI.openTab({
            pageReference: {
                "type": "standard__recordPage",
                "attributes": {
                   "recordId": selectedAccountGetFromEvent.Id,
                    "actionName":"view"
                },
                "state": {}
            },
            focus: true
        }).then(function(response) {
            workspaceAPI.getTabInfo({
                tabId: response
        }).then(function(tabInfo) {
            console.log("The recordId for this tab is: " + tabInfo.recordId);
        });
        }).catch(function(error) {
            console.log(error);
        });
navEvt.fire();
    },
   
    handleComponentEvent : function(component, event, helper) {
          var navEvt = $A.get("e.force:navigateToSObject");
        var workspaceAPI = component.find("workspace");
        workspaceAPI.openTab({
           "recordId": selectedAccountGetFromEvent.Id,
            focus: true
        }).then(function(response) {
            workspaceAPI.getTabInfo({
                  tabId: response
            }).then(function(tabInfo) {
            console.log("The url for this tab is: " + tabInfo.url);
            });
        })
        .catch(function(error) {
               console.log(error);
        });
navEvt.fire();
    },
    
   
    handleComponentEvent : function(component, event, helper) {
          var navEvt = $A.get("e.force:navigateToSObject");
        var workspaceAPI = component.find("workspace");
        //var URLlink= HYPERLINK("https://csp2dev-mergedealer.cs102.force.com/CSPDealerCommunity/s","_self" );
        workspaceAPI.openTab({
            url: URLlink,
            focus: true
        }).then(function(response) {
            workspaceAPI.getTabInfo({
                tabId: response
            }).then(function(tabInfo) {
            console.log("The recordId for this tab is: " + tabInfo.recordId);
            });
        }).catch(function(error) {
                console.log(error);
        });
navEvt.fire();
    },

    
    
    Thanks in advance

 
Anil Bolisetty 2Anil Bolisetty 2
WorkSpace API works only in lighnting console.