2

I have a different lightning flexipage intended for different record types. When I click a button on the page it changes the record type (using apex). When I get back from the action I want to refresh the current page so that I can now see the new flexipage.

There are times that this works, but for some reason many times it does not. Is there a reason why at times the refresh doesn't work?

This is a lightning console app.

What I've Tried

  1. $A.get('e.force:refreshView').fire();
  2. workspaceAPI.closeTab({tabId: tabId});...

    together with...

    workspaceAPI.openTab({ recordId: recordId, focus: true });

  3. const navEvt = $A.get('e.force:navigateToSObject'); navEvt.setParams({ 'recordId': recordId, 'slideDevName': 'related' }); navEvt.fire();

  4. const navService = component.find('navService'); const pageReference = { type: 'standard__recordPage', attributes: { recordId: recordId, objectApiName: 'Record__c', actionName: 'view' } }; navService.navigate(pageReference);

7
  • When the refresh does not work, do you still see the old record type shown in the Record Type field on the page?
    – David Reed
    Jan 1, 2019 at 14:34
  • @DavidReed I'm not using the 'Details' tab, so I don't see the Record Type field. I can try to put it back for a moment to see it that's the case.
    – shmuels
    Jan 1, 2019 at 14:37
  • @DavidReed I just tried it now and yes I still see the old Record Type in the Record Type field.
    – shmuels
    Jan 1, 2019 at 14:40
  • Is there a Visualforce-backed button involved? I'm wondering if it's related to this known issue.
    – David Reed
    Jan 1, 2019 at 14:42
  • @DavidReed It's all in Lightning, no Visualforce. <lightning:button...
    – shmuels
    Jan 1, 2019 at 15:07

1 Answer 1

1

I do find that one way to force recent Apex updates to be "seen" by the client-side cache is by forcing Lightning Data Service to reload the record. So the same component that is calling the Apex could have an instance of force:recordData pointing to that record ID with a FULL layout. It doesn't have to actually use it for anything. Upon return from Apex it can fire the reloadRecord method of LDS. I have noticed upon doing this, changed fields will update themselves in the Details panel.

I don't know if this is good enough to also force the change in Flexipage layout. But it's worth a shot. reloadRecord takes a callback argument so you can have your console API stuff run after the reload has completed.

1
  • Thank you. I will look into this and see if it will work.
    – shmuels
    Jan 1, 2019 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .