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
Mike WaughMike Waugh 

Can I Invoke Apex code from a custom field formula?

I have a custom field that I have added to the Leads search results that I want to be able to invoke some custom code.  Is there any way that you can use a HYPERLINK tag to target an apex class?  Right now, my custom field contains a formula as follows:

 

I want to be able to manipulate data that is associated to the record in which I have added the custom field upon a user clicking this field within the search results screen before posting the results to an external server.  Is this even possible?

Thanks
Navatar_DbSupNavatar_DbSup

Hi,

 

I think this is not possible to directly call apex class from a custom formula field. You can call apex class from the vf page and call the vf page from custom link.

 

For example :

HYPERLINK("apex/pagename","Click here")

 

Another way you can create a custom link from the button and links then you can directly apex class from that link.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

 

 

juysolutionsjuysolutions
As navatar mentioned, you would need to create a VF page and call the method you want to execute from your class on page load like so:
<apex:page controller="YourControllerClass" action="{!executeMethod}"></apex:page>
Then you can create a HYPERLINK formulat call the VF page like on navatar's example.

Below is an example of a clickable formula field that displays as a button:
HYPERLINK('/apex/MyVFPage?param1=value1&param2=value2&id=' + Id, IMAGE('/resource/1441184702000/Button_Image', 'Click Me')
Hope this helps!