0

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 :

 {!$ObjectType.Contact.fieldsets.Validate_Fields}

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.

0

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. – hok Ashukar Sep 22 at 7:19
  • they wont have the choice eventually – glls Sep 22 at 20:12

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.