2

I want to create function for reopening(refreshing) component or whole opened tab by clicking on the button.

I couldnt find any working example. I am using aura lightning component.

cmp:

<lightning:button label="Storno" onclick="{!c.storno}" aura:id="new-trans-button"/>

controller:

storno : function (cmp, event, helper) {
        var subtabId = 'scc-st-0';
        sforce.console.refreshSubtabById(subtabId, true, refreshSuccess);

I used something like this, but i dont know how to get subtabId and i am getting error

sforce is not defined
0

You can access the console API via the lightning:workspaceAPI component. This has methods such as refreshTab that:

Refreshes a workspace tab or a subtab specified by tabId. Keep in mind that the first subtab has the same tabId as the workspace tab.

This component provides a "service" rather than rendering UI directly. Include it on your component and find it by its aura:id and invoke its methods.

Note that Promises are used in many methods to allow asynchronous completion.

| improve this answer | |
0

you should use RefreshTab() method from lightning:Worksapce API.

PFB the sample Code:

<aura:component implements="flexipage:availableForAllPageTypes" access="global">
<lightning:workspaceAPI aura:id="workspace"/>
<lightning:button label="Refresh Focused Tab" onclick="{!c.refreshFocusedTab}"/>

Js Code

({
refreshFocusedTab : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.getFocusedTabInfo().then(function(response) {
        var focusedTabId = response.tabId;
        workspaceAPI.refreshTab({
                  tabId: focusedTabId,
                  includeAllSubtabs: true
         });
    })
    .catch(function(error) {
        console.log(error);
    });
}

})

for More info visit this link: https://developer.salesforce.com/docs/atlas.en-us.api_console.meta/api_console/sforce_api_console_lightning_refreshTab.htm

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.