- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 07:51 AM - edited 07-26-2023 07:55 AM
Is it possible to change the question value based on condition?
For example, we've a catalog item wherein multiple variables available like:
-service provider(multiple choice[a,b,c,d]).
-request type(multiple choice--[x,y]).
-account number(single line text)
when service provider is 'b' and request type is 'y', then the variable 'account number' should be changed to 'account ID'(only the question should change).
#itsm #catalog item
There is an option to create 2 variables each for account number and account ID, then use Catalog UI policy based on condition; however, is there any other way to do it without creating multiple variables. I've tried onchange CS with g_form.setLabelof() but isn't helping.
Gurus, please help me with the Catalog CS code..
Thanks in Advance
Solved! Go to Solution.
- Labels:
-
Continual Improvement (CIM)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 08:46 AM
Hello @Snow_Hustler42 ,
Hope you are well!
In the catalog item, when 'Service Provider' is 'b' and 'Request Type' is 'y', dynamically change the label of the 'Account Number' variable to 'Account ID'.
Solution:
1. We have to configure 2 onChange client scripts for the variables 'Service Provider' and 'Request Type' like below.
#onChange Client Script for Service Provider:
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//g_form.addInfoMessage(newValue + "\n" + g_form.getValue('request_type'));
//Type appropriate comment here, and begin script below
if (newValue == 'b' && g_form.getValue('request_type') == 'y') {
g_form.setLabelOf('account_number', 'account ID');
} else {
g_form.setLabelOf('account_number', 'account number');
}
}
# 2 onChange Client Script for 'Request Type':
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
//g_form.addInfoMessage(newValue + "\n" + g_form.getValue('service_provider'));
//Type appropriate comment here, and begin script below
if (newValue == 'y' && g_form.getValue('service_provider') == 'b') {
g_form.setLabelOf('account_number', 'account ID');
} else {
g_form.setLabelOf('account_number', 'account number');
}
}
If this helped you in any way, please hit the like button/mark it helpful. Also, don't forget to accept it as a solution. So it will help others to get the correct solution.
thanks,
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2023 09:47 AM
Tried and isn't working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2023 03:06 AM
Hi @Snow_Hustler42
you got any solution regrding this requirement. I am also having the same requirement like mentioned above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 02:14 AM - edited 04-12-2024 02:16 AM
Nope, I've confirmed the client that it's not a feasible option. Instead, I created 2 variables and hidden one of them using UI policy based on requirement. Having 2 questions for 1 variable will conflict in server side. Hence, it's not feasible