- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13 hours ago
show or hide the variable on the basis of choices can any one help me with this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13 hours ago
it's an easy requirement
something like this in onChange client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'value1') {
g_form.setDisplay('variable1', true);
} else {
// make non mandatory and then hide
g_form.setMandatory('variable1', false);
g_form.setDisplay('variable1', false);
}
}
š” If my response helped, please mark it as correct ā and close the thread šā this helps future readers find the solution faster! š
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
13 hours ago
it's an easy requirement
something like this in onChange client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'value1') {
g_form.setDisplay('variable1', true);
} else {
// make non mandatory and then hide
g_form.setMandatory('variable1', false);
g_form.setDisplay('variable1', false);
}
}
š” If my response helped, please mark it as correct ā and close the thread šā this helps future readers find the solution faster! š
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago - last edited 10 hours ago
Hi @RoshaniB
Another option without scripting is to use a Catalog UI Policy. You can show or hide a variable by defining a condition based on the userās selection. In the Catalog UI Policy Actions, choose the variable you want to control and set Visible = true or false. If you also check the āReverse if falseā option, the system will automatically apply the opposite visibility when the condition is not met, without the need for scripting.
Here are the documentation links for reference (Service Catalog UI Policies):
Thanks and Regards
Mohammed Zakir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
9 hours ago
Here is the Example for Catalog UI policy
1) Create Catalog UI policy. Example:
a) UI policy when monthly_data_allowance choice is 500 MB
2)Create A UI Policy Action example:
3) UI policy Action configuration Example:
The varaible what_was_the_original_phone_number is visible and mandatory only if above condition matches
Result Verification:
4) Variable is hidden when choice is not 500 MB
5) Shows variable only when choice condition matches i.e. 500MB
Thanks and Regards,
Mohammed Zakir