I have to check a field of a related record in my onclick javascript button.

Is it possible? for instance:

var fieldValue = '{!Object__c.LookupField__r.Field__c}'

Or is the only alternative to call an apex method to retrieve that value?

I didn't find an answer for this anywhere..

(We have a button for lightning experience, this is for our clients that still use classic)


1 Answer 1


No, you can't, and no, you don't need Apex, either. You can use the REST API via the AJAX Toolkit to get the information you want:

  (result) => {
  • Thank you very much! I thought searching for my problem directly would bring up a solution but maybe I should read the documentation on the ajax toolkit. Nov 10, 2022 at 20:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .