How to find which field/variable are avaliable on catalog form at Service Portal using client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2025 09:29 AM - edited ‎01-06-2025 09:29 AM
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.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 12:44 AM
you can't determine whether variable on catalog form (during submission) is present on RITM/SCTASK
what's your business requirement?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 02:39 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 02:49 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 06:13 AM
Thanks @Ankur Bawiskar , will try to check your suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2025 06:21 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader