- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2025 11:45 PM
HI Community,
I have a requirement, in catalog form we have a variable called software (reference to software install table) and price variable (single line). in software install table there is field called Licence Type
When user selects any software in software variable and its licence type is licensed then show the price variable in form if not do not show this.
Please provide me the catalog client script and script include.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 01:07 AM
you cannot do this with UI policy.
You will have to use onChange client script with getReference callback and check the type and then show/hide the other variable
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var ref = g_form.getReference('softwareVariable', callBackMethod); // software variable name
}
function callBackMethod(ref) {
// compare correct field name and choice value for licensed
if (ref.licenseTypeField == 'licensed')
g_form.setDisplay('otherVariable', true); // give other variable name here
else
g_form.setDisplay('otherVariable', false); // give other variable name here
}
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
07-04-2025 12:07 AM
It's an empty string variable that you want to show? I am not sure what the use will be, but you can easily get it there by adding a hidden (choice) variable that you let autofill on software selection (option on the variable form no need for scripting). You can then use a catalog ui policy or client script on the price field to show if that hidden field is 'licensed'.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 12:29 AM
HI @Mark Manders ,
Thanks for replying
My requirement is when user select any software in software variable it needs to check the licensed type of that software if the type is licensed then price variable needs to be visible in form
How can we achieve this without script in UI Policy i tried i think we cannot do that via policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2025 01:07 AM
you cannot do this with UI policy.
You will have to use onChange client script with getReference callback and check the type and then show/hide the other variable
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
var ref = g_form.getReference('softwareVariable', callBackMethod); // software variable name
}
function callBackMethod(ref) {
// compare correct field name and choice value for licensed
if (ref.licenseTypeField == 'licensed')
g_form.setDisplay('otherVariable', true); // give other variable name here
else
g_form.setDisplay('otherVariable', false); // give other variable name here
}
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
07-04-2025 02:36 AM
HI @Ankur Bawiskar ,
Thanks for the reply
Yes it works but not sure why im getting the console error