1

TL;DR(edited): We have a quick action calling a lightning component that will perform an outbound WS call from APEX, update the current record and then refresh the view.

We use the function : workspaceAPI.refreshTab(...);

Problem: The sub-tab record view is refreshed only if the user didn't navigate across sub-tabs on the Lightning Service Console. Technically, if the user navigates across tabs and sub-tabs, the workspaceAPI becomes undefined.

Questions (edited):

  • The workspaceAPI is supposed to be friendly with the Lightning Console. Am I missing something to handle subtabs ?
  • The native JS 'location.reload()' function works as a workaround but is a disgusting solution (the whole page being reloaded with the splash screen). Would you suggest an other one ?
  • As 'location.reload()' seems the only workaround. I went for a hybrid solution figuring out if we can refresh cleanly (force:refreshview) or do the dirty refresh in case of error. Would you suggest an other out-of-the-box solution ?

Thanks in advance,

Details:

  • Lightning component embedded in a quickAction on the page layout called upon pressing the button
  • The refresh part in the Helper:

        actionOr.setCallback(this, function (a) {
    
            var messageType = '';
    
            if (a.getReturnValue() == "someStuff1")
                messageType = 'info';
            else if (a.getReturnValue() == "Somestuff2")
                messageType = 'success';
            else
                messageType = 'error';
    
            toastEvent.setParams({
                mode: 'dismissible',
                type: messageType,
                title : 'Simple Title',
                message: a.getReturnValue()
            });
            toastEvent.fire();
                    component.find("workspace").getFocusedTabInfo().then(function (response) {
                        $A.get('e.force:refreshView').fire();
                        component.find('subProcRecord').reloadRecord();
                        var focusedTabId = response.tabId;
                        workspaceAPI.refreshTab({
                            tabId: focusedTabId,
                            includeAllSubtabs: true
                        });
                    }).catch(function (error) {
                        console.log('Error is : ' + error);
                        location.reload();
    
                    });
            var dismissActionPanel = $A.get("e.force:closeQuickAction");
            dismissActionPanel.fire();                
    
        });
    
        $A.enqueueAction(actionOr);
    
  • The target browser is : Firefox ESR 52.8.1

  • We are using Lightning Console

  • We declared the workspaceAPI in the cmp : <lightning:workspaceAPI aura:id="workspace" />
  • a server side apex will not trigger anything on your component, you should wait for the apex method to come back and then trigger the refresh. also you are using a standard refresh ($A.get("e.force:closeQuickAction");) this will trigger refresh only to standard components that listen to it, or to your custom component - if you implement a listener to it – Itai Shmida Jun 17 '18 at 6:47
  • 1
    @ItaiShmida : The issue is a bit trickier actually : it comes from tab and sub-tab switching in the Lightning Service Console which makes the refresh event fail. I transformed the code to use the workspaceAPI but I'm still getting issues upon tabs and subtabs swapping. Other than that, I'm already in a callback so I'm already waiting for the apex method to come back... – Answers_Seeker Jun 20 '18 at 15:44

Your Answer

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

Browse other questions tagged or ask your own question.