How to find which field/variable are avaliable on catalog form at Service Portal using client script

Prabhu4
Tera Contributor

Hi All,

I have requirement to update only the variable/fields available on the form at service portal and not RITM/SCTASK.
but I am unable to get that information in catalog client script as g_form.getFieldNames() or g_form.isVisible() methods are not available/deprecated in Xanadu version.

So can you please help me or guide me how I can get the fields names that are available in current form through client Script.


Thank you in advance.

 

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@Prabhu4 

you can't determine whether variable on catalog form (during submission) is present on RITM/SCTASK

what's your business requirement?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar ,

We need to update the variables available on the form using catalog client script by fetching values from different RITM, so we wrote the script include to fetch the values from option table and calling the same in catalog client script. At portal level everything working as expected that means the values are getting updating but the issue is even the values that are available in SCTASK level are also getting updated which we need to stop.

Lets say we have 10 fields on the catalog 3 fields are hidden using UI policy to display only on SCTASK level and not on portal level. So this is the reason we wanted to have a filter the variable update by checking if it is available on portal or not.

Thank you for the response.

@Prabhu4 

in script you cannot determine if those 3 variables were hidden or not via some UI policy on catalog form.

This is somewhat difficult to handle.

what you can do is this but that also doesn't guarantee

1) whatever is the UI policy's condition check if that UI policy condition is satisfied or not based on catalog variable and if yes then check in UI policy action if that variable is shown/hidden

Based on that you can exclude it from your list

This workaround requires to evaluate all the ui policies on that catalog item to determine.

What if there are complex client scripts which are showing/hiding the variable?

So I will suggest you to inform the business that this is not feasible and even if somehow you achieve it would be very difficult going forward to maintain the code and upgrade (considering a new client script or UI policy is added on that catalog item)

I believe I have provided enough guidance for your question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks @Ankur Bawiskar , will try to check your suggestions.

@Prabhu4 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader