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
SchuetzlerSchuetzler 

Trigger when Account is viewed

I am looking for a way to run Apex code, or possibly a trigger, whenever an Account is viewed. The Apex code will be used to update a field at the account level, but I don't want to wait for the Account to be updated.

 

Is this possible?

Best Answer chosen by Admin (Salesforce Developers) 
mtbclimbermtbclimber

If you mean when a user clicks on the link to navigate to the account detail page in the salesforce.com UI then you can if you override the view action for account with a visualforce page and then hook your apex to the page's action attribute.

All Answers

mtbclimbermtbclimber

If you mean when a user clicks on the link to navigate to the account detail page in the salesforce.com UI then you can if you override the view action for account with a visualforce page and then hook your apex to the page's action attribute.

This was selected as the best answer
gtindugtindu

An option might be a visualforce page you put on the page layout...

Or, alternately, you can override the detail page in order to add this functionality.

SennahSennah

You could indeed put a visualforce page in the page layout and call some code in the controller.

Have a look at my "Account Last Viewed by" solution... Just install into your development organization:

 

https://login.salesforce.com/?startURL=%2Fpackaging%2FinstallPackage.apexp%3Fp0%3D04tA00000005Ww6

 

Adapting the controller should be easy.

 

Have fun!

//Hannes