vaishali231
Mega Sage

Hey @Alon Grod 

 Business Rule runs server-side, it cannot directly determine whether a field or Record Producer variable was visible on the user's form.you can use client side  APIs g_form.isVisible() 

For  task fields using current.getElements() and the Record Producer variables using:

var variables = current.variables.getElements();

for (var i = 0; i < variables.length; i++) {

    gs.info(variables[i].getLabel() + ' = ' + variables[i].getValue());

}

 

For  PDF to contain exactly what was visible to the user at submission time, the better approach is to capture the visible fields/variables on the client side and store them .

Then the Business Rule can read that data, generate the PDF, and attach it to the task.

*************************************************************************************************************************************

If this response helps, please mark it as Accept as Solution and Helpful.

Doing so helps others in the community and encourages me to keep contributing.

Regards

Vaishali Singh
Linkedin - https://www.linkedin.com/in/vaishali-singh-2273361bb










OlaN
Tera Sage

Hi,

What's the use of a PDF containing all the visible fields on the form ?
All the data is already there, visible on the form, then why the PDF ?

masonreed11
Tera Contributor

Yes, it’s possible, but a Business Rule can’t directly know the client-side visibility of fields. You can use GlideRecord and dictionary metadata for fields, and access the record producer variables separately.

I’d recommend having the Business Rule call a Script Include that collects the required label/value pairs, generates the PDF, and attaches it with GlideSysAttachment.

masonreed11
Tera Contributor

Yes, but not directly from a Business Rule. A Business Rule can read the record fields and variable values, but the form/UI controls visibility. You’ll need to reproduce the visibility logic server-side or use a suitable PDF/reporting approach to generate the attachment.

Ankur Bawiskar
Tera Patron

@Alon Grod 

what's the business requirement here?

In server side you won't know which variables are visible or not.

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏