• DEV SFDC 28
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Salesforce experts,

I have following use case:
A custom object related to an Account.
The related list is added into Account's page layout.
From a custom button a Visualforce page is opened, which initializes the custom object, fills the values and saves it.
After clicking the confirm button on VF page, the user is redirected back to Account page.

Everything works as designed on SF Classic.
BUT on Lightning the related list is not updated, although the object is created successfully. First after clicking the related list or refreshing the page manuelly, new record is shown.

<apex:commandButton> contains action returning redirected PageReference is tried first:
VF page:
......
<apex:commandButton value="AddList" action={!addList}"/>
......
Controller:
......
public PageReference addList() {

  // Logic to create custom object. 
 
 PageReference pageRef = new PageReference('/' + ApexPages.currentPage().getParameters().get('id')); 
 pageRef.setRedirect(true);
 return  pageRef;
}
......

If commandButton action returns redirection (pageRef is set), JS in oncomplete is not triggered. None of the following works. Just for test purposes.
<apex:commandButton value="AddList" action={!addList}" oncomplete="alert('blabla');"/>
<apex:commandButton value="AddList" action={!addList}" oncomplete="window.opener.location.refresh();"/>
<apex:commandButton value="AddList" action={!addList}" oncomplete="sforce.one.navigateToSObject('objId');"/>

Aliasing controller method through <apex:actionFunction> then JS:
......
<script>
  function myComp() {
  	  addListAction();
  	  sforce.one.navigateToURL('objId');
	  //alert('blabla');
  }
</script>
<apex:actionFunction name="addListAction" action="{!addList}"/>
<apex:commandButton value="AddList" oncomplete="myComp();"/>
......
JS is triggered but no effect on Lightning.

This is already an old question but no answer could be found by searching through the community/internet.
I really hope someone already found a workaround (without using Lighting component or event) and can help me out here.
Tried suggestions from these resources and much more, none of them works.
https://www.forcetalks.com/salesforce-topic/navigate-to-url-is-not-refreshing-the-page-in-salesforce-lightning/
https://developer.salesforce.com/forums/?id=906F0000000MGSsIAO
Salesforce experts,

I have following use case:
A custom object related to an Account.
The related list is added into Account's page layout.
From a custom button a Visualforce page is opened, which initializes the custom object, fills the values and saves it.
After clicking the confirm button on VF page, the user is redirected back to Account page.

Everything works as designed on SF Classic.
BUT on Lightning the related list is not updated, although the object is created successfully. First after clicking the related list or refreshing the page manuelly, new record is shown.

<apex:commandButton> contains action returning redirected PageReference is tried first:
VF page:
......
<apex:commandButton value="AddList" action={!addList}"/>
......
Controller:
......
public PageReference addList() {

  // Logic to create custom object. 
 
 PageReference pageRef = new PageReference('/' + ApexPages.currentPage().getParameters().get('id')); 
 pageRef.setRedirect(true);
 return  pageRef;
}
......

If commandButton action returns redirection (pageRef is set), JS in oncomplete is not triggered. None of the following works. Just for test purposes.
<apex:commandButton value="AddList" action={!addList}" oncomplete="alert('blabla');"/>
<apex:commandButton value="AddList" action={!addList}" oncomplete="window.opener.location.refresh();"/>
<apex:commandButton value="AddList" action={!addList}" oncomplete="sforce.one.navigateToSObject('objId');"/>

Aliasing controller method through <apex:actionFunction> then JS:
......
<script>
  function myComp() {
  	  addListAction();
  	  sforce.one.navigateToURL('objId');
	  //alert('blabla');
  }
</script>
<apex:actionFunction name="addListAction" action="{!addList}"/>
<apex:commandButton value="AddList" oncomplete="myComp();"/>
......
JS is triggered but no effect on Lightning.

This is already an old question but no answer could be found by searching through the community/internet.
I really hope someone already found a workaround (without using Lighting component or event) and can help me out here.
Tried suggestions from these resources and much more, none of them works.
https://www.forcetalks.com/salesforce-topic/navigate-to-url-is-not-refreshing-the-page-in-salesforce-lightning/
https://developer.salesforce.com/forums/?id=906F0000000MGSsIAO