function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jonathan SpinkJonathan Spink 

How do I get a VF page to autorun without user input?

We have a merge process that takes the user through several pages by them clicking 'Save' each time. How can I get this to run without requiring any user input?
Best Answer chosen by Jonathan Spink
ShivankurShivankur (Salesforce Developers) 
Hi Jonathan,

Thanks for adding more input to the concern.

That doesn't seem to be valid use case, since if you try to autosave the populated or filled fields everytime when typed then it would make multiple callouts to database and save the details.

There should always be a mechanism, which lets the user to add the details as they want and upon filling the complete details, then only should make an attempt to reach to database and save.So, save button should be clicked as consent from user, everytime when need to save it to database.

If you want single button for all the fields filled in last screens or last VF pages then using flow with screen elements would be a good choice which shows interactice experience while saving multi page details or forms.

Check out how you can use flow builder to make this possible:
https://trailhead.salesforce.com/en/content/learn/modules/flow-builder/flow-builder-screens

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.

All Answers

ShivankurShivankur (Salesforce Developers) 
Hi Jonathan,

As per the description, it looks like you want to pre-populate the details in your VF page and just click 'save' button to merge the data and which would run without requiring any user input.

Here are few threads sharing examples by community members:
https://developer.salesforce.com/forums/?id=9060G0000005kJeQAI
https://developer.salesforce.com/forums/?id=906F0000000BLy5IAG

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
Jonathan SpinkJonathan Spink
Thanks Shivankur. I don't actually need to pre-populate any fields, I just need to click the 'Save' button automatically (in code) so the user doesn't have to. Does that make sense?
ShivankurShivankur (Salesforce Developers) 
Hi Jonathan,

Thanks for adding more input to the concern.

That doesn't seem to be valid use case, since if you try to autosave the populated or filled fields everytime when typed then it would make multiple callouts to database and save the details.

There should always be a mechanism, which lets the user to add the details as they want and upon filling the complete details, then only should make an attempt to reach to database and save.So, save button should be clicked as consent from user, everytime when need to save it to database.

If you want single button for all the fields filled in last screens or last VF pages then using flow with screen elements would be a good choice which shows interactice experience while saving multi page details or forms.

Check out how you can use flow builder to make this possible:
https://trailhead.salesforce.com/en/content/learn/modules/flow-builder/flow-builder-screens

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
This was selected as the best answer
Jonathan SpinkJonathan Spink
OK, thanks for your input. I have read elsewhere that because Apex runs on the server and the VF page is client side there is no easy way to autoclick the button, not without some Javascript perhaps.