1

I currently have a custom button on a custom object that calls a Visualforce page with a custom controller. This page & controller does some calculations and refreshes data in a related list on my object when the user presses the button. Rather that having the user press the button, I would like the calculations to occur once the page has been loaded and/or refreshed. Is there a way to automatically call the VF page and controller when the page loads?

VF Page:

<apex:page standardController="Quote__c" extensions="ControllerNew" action="{!init}">
    <apex:pageMessages id="pgMess" />
    <apex:form id="frmEntReview" > 

    </apex:form>        
</apex:page>
  • I don't understand why the act of viewing the parent record needs to force a recalc of the child related objects. If you need to recalc the child objects whenever the parent record is changed, why not use a trigger? – David Cheng Sep 25 '18 at 17:51
  • It's using our CPQ instance. The child records are calculated as part of the CPQ processes. The VF page above is a separate calculation. We run into CPU limits when we try to do both at the same time. Putting the VF page on the parent record after the child calculations have completed resolves this. – J. Neilan Sep 25 '18 at 19:33
1

You can include the VF page as an embedded component on the page layout. This would cause the page and its controller to be invoked when you view the record page (without having the click anything) - which sounds like what you are after.

However if this is changing data on a child object shown as a related list then these changes would be after the page has loaded and so you would still need to refresh the page to see the new values in the related list.

| 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.