+ Start a Discussion
Tolga SunarTolga Sunar 

Page redirect problem in SF1 custom quick action button for Approving a record

Hello,

I am developing a custom object-specific quick action for letting users approve or reject a record which has a pending approval request, on SF1. I've set up a VF and controller, and they work as intended; upon clicking on quick action, record becomes approved.

However, I am trying to make the quick action button to redirect back to record detail page. Instead, it simply brings the comment insertion page with "Save" button greyed out and no comment textbox. I have to click "cancel" to navigate back to record detail page that is not refreshed (fields come out as not updated by approval actions etc...)

Here is my Visualforce code:
<apex:page standardController="PR_PO__c" extensions="ApproveActionVfc" action="{!redirect}">
    <script> 
    try { sforce.one.navigateToURL('/{!PR_PO_ID}'); } 
    catch(e) { window.location.href = '/{!PR_PO_ID}'; }
    </script> 
</apex:page>
PR_PO_ID here is the record ID that is fetched inside and transferred from the extension.
On desktop interface, redirection is successful, however on SF1 I have this problem. 

Screenshots (record detail page and the page upon clicking (the popup saying "Record is Approved" appears shortly after this page shows up).
User-added image

User-added image

Any help or idea is greatly appreciated. I think this is unfixable because of SF1 design, but I hope that someone already encountered this problem and found a solution...

Thanks in advance.
Best Answer chosen by Tolga Sunar
Dushyant SonwarDushyant Sonwar
Hi Tolga,

You can try out with "navigateToSObject" method
sforce.one.navigateToSObject('/{!PR_PO_ID}');
If that didn't work out then you can also give this a shot
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ refresh:"true"}});

Hope this will help you.
Thanks 

All Answers

Tolga SunarTolga Sunar
I would like to also point out that:
  1. In the apex:page tag, the defined  action has nothing to do with redirection as opposed to its name. I copied that from another code and did not rename. This action simply approves the current approval request in the extension.
  2. sforce.one.navigateToSObject does not work as well.
Thanks.
Dushyant SonwarDushyant Sonwar

Hi Tolga,

Did you included following script in your page?

<script type='text/javascript'  src="/sforce/one/30.0/api.js" />
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
Tolga SunarTolga Sunar
Hi Dushyant,

I did not include that script. I have just added that to my code and did a test, unfortunately it didn't fix the problem.

Thank you anyway for your interest on this topic
Dushyant SonwarDushyant Sonwar
Hi Tolga,

You can try out with "navigateToSObject" method
sforce.one.navigateToSObject('/{!PR_PO_ID}');
If that didn't work out then you can also give this a shot
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ refresh:"true"}});

Hope this will help you.
Thanks 
This was selected as the best answer
Tolga SunarTolga Sunar
Hi Dushyant,

My apologies for such a late answer. I've set this issue as idle, since this is an optional development in my schedule. If I ever have to revise this development in the future, I will certainly take your latest suggestions in consideration! Thanks a lot for your interest again.