I am working with a Javascript button to validate fields before the button can update fields.

Since there are over 20 fields to validate, (With the possibility of adding more) listing out each field in the Javascript Button and checking if it is blank would be very hard to maintain.

So I was wondering if it was possible to reference a field set in javascript? I tried using :


But it throws an Error: Field Contact.fieldSets.Validate_Fields does not exist. Check spelling.

Is there a different way to reference a fieldset in javascript?

I am only using a button, I have seen fieldsets being used in visualforce/apex but am wondering if it is possible with just javascript from a detail page button.

1 Answer 1


No, you can't use field sets in JavaScript buttons. Also, JS buttons are effectively deprecated, as they do not work in Lightning Experience. Consider writing a Lightning Component Quick Action instead. From there, you can load the field set from a simple Apex function call, and verify the information that way (using Lightning Data Service to retrieve the record). See the force:lightningQuickAction interface documentation for more details.

  • My client is currently in classic and are not transitioning to lightning. Thanks for the feedback. Sep 22, 2019 at 7:19
  • they wont have the choice eventually
    – glls
    Sep 22, 2019 at 20:12

You must log in to answer this question.

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