I´ve been thinking about this today and found one solution using a formula field, but I want to know if there´s any chance that every time a user clicks the view on a record, it gets automatically updated before it is showed to them.

for example lets say you have a visualforce page to override the view page, and you have a controller extension to work with it, how you update the record if the user haven´t commit any changes, they just clicked on the link or the view button record

  • If you set a view override to a Visualforce page, it does not matter where the using is calling the page from, the view will always be that VF page.
    – greenstork
    Oct 4, 2013 at 21:09
  • Yes indeed, but how you trigger an action, let´s say you need to get the current time zone when the user accessed that record and compare it to one field in the object and then update one block of the VF page
    – Emilio
    Oct 4, 2013 at 21:12
  • Sounds like in that case, you're just writing logic into your Visualforce page/controller. I'm confused about what this has to do with the View, which is what you asked about.
    – greenstork
    Oct 4, 2013 at 21:40
  • I edited the question, so basically that is so, every time a user access a record from the view or link to the record it must perform a specific action like an update
    – Emilio
    Oct 4, 2013 at 21:50
  • Are you saying you want to take an action (e.g., execute DML to update the database) when a VF page is loaded, before the page is displayed? Can you give a more specific example? A sample VF page, with an explanation of the change you want to accomplish on load, would help us understand the question. Oct 4, 2013 at 22:00

1 Answer 1


Actions on a page can be called in a few different ways. You can call an action in your controller from the loading of the page via a page action or within the constructor when the page loads (it's worth noting that DMLs are not allowed in the constructor).

Alternatively, you could use Javascript and a Javascript remoting call to go fetch some data, perform an action of some sort, and then adjust the view accordingly.

Lastly, you can use an actionFunction, which is essentially a Visualforce AJAX layer.

Here is a good help article explaining the visualforce order of execution on a page load: http://www.salesforce.com/us/developer/docs/pages/Content/pages_controller_lifecycle_example.htm

Here is a link to Javascript Remoting documentation: http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting.htm

Here is a link to actionFunction: http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm

Because your question isn't quite clear, I'll offer one last comment. If you're just trying to interpret a field on your record, based on data from other fields or even the user, then a formula field may be appropriate. Formula fields are just custom logic to interpret the underlying data. They're not actually changing anything, they are just a static interpretation of data.

  • Thanks, sorry for not being so clear on this, onLoad is what I was looking for!
    – Emilio
    Oct 4, 2013 at 22:56

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.