1

I have an inline visualforce page on Case layout. When the case page is loaded, this loads the vf page and there is an action call on the inline vf.

<apex:page name="xyz" standardController="Case" extensions="xyzcallout" action="{!WebServiceMethod}">

The WebServiceMethod method is a callout to external application. Based on the values coming in from the callout Case.Status is updated.

if(field_name == 'Defined'){
         cas.Status = 'Approved';
         System.debug(cas.Status);
         update cas;
}

However, the Case layout doesn't show the update until the second refresh. On page load case still shows old status while inline VF page shows new status. On refresh, Case Status shows new value.

   <script>
 function refreshPage(){
  window.top.location="/{!Case.id}";
  return false;
  } 
 window.onload = setTimeout(function(){refreshPage()},2000); 
 </script>

I tried using the above javascript to reload page on completion of action but it doesn't seem to work for me.

My Question: Is there a way to update the Case field after inline VF load action without a button click or any user action.

  • You'll have to refresh the parent page from the inline VF using Javascript when the action completes. – Adrian Larson Feb 15 '17 at 19:56
  • Thanks Adrian. I am using the above javascript but it doesn't work for me. Could you let me know what I am missing? – Vick Feb 15 '17 at 20:01
  • Does it actually execute? If not check your Javascript for errors. You may need to set a timeout so it executes after the callout completes. – Adrian Larson Feb 15 '17 at 20:02
  • Yes, It executes without the return false; however it goes into an infinite loop and keeps on refreshing. With the return false; it doesn't execute. Updated the original question with js code. – Vick Feb 15 '17 at 21:10
  • You'll need to make sure you only fire this script if the update is necessary. Should suffice to add a Boolean property that tells you if field_name == Defined' && cas.Status != 'Approved'. – Adrian Larson Feb 15 '17 at 21:12
1

Thanks for your help Adrian. I got it to finally work using sessionStorage.

<script>
 setTimeout(function(){
 if ( !sessionStorage["reloaded"] ){
            sessionStorage["reloaded"] = true
            window.top.location='/{!Case.id}'; return false;
            }
            }, 2000);
 </script>
| 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.