- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 01:03 AM
Hi All,
I have requirement that basically there is one choice field, under choice field there description field also, so for every choice we have some text input, So whenever we select above choice 1, under decsription field we need to fill that input text automatically? like that for all other choices also need to fill corresponding text in description field?
Please help me on this
Thanks
Deepika
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 01:15 AM - edited 10-11-2022 01:19 AM
Try onChange() Catalog Client Script on your choice variable and set the value of text field under the choice field. Something like below in client script should work.
var choiceValue = g_form.getValue('<choice_variable_backend_name>');
if(choiceValue == '<some_choice_backend_value>'){
g_form.setValue('<text_input_variable_backend_name>', 'some text');
} else if(choiceValue == '<some_choice_backend_value>'){
g_form.setValue('<text_input_variable_backend_name>', 'some text');
}
You can also try with switch cases instead of if-else.
If you just want to set the choice value to the text field, then utilize the below script.
var choiceValue = g_form.getValue('<choice_variable_backend_name>');
g_form.setValue('<text_input_variable_backend_name>', choiceValue);
// To set the lable of choice value, utilize the below statement.
//g_form.setValue('<text_input_variable_backend_name>', g_form.getOption('<choice_variable_backend_name>', newValue).text);
To map the text variable value to description, use map to field in variable configuration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2022 01:15 AM - edited 10-11-2022 01:19 AM
Try onChange() Catalog Client Script on your choice variable and set the value of text field under the choice field. Something like below in client script should work.
var choiceValue = g_form.getValue('<choice_variable_backend_name>');
if(choiceValue == '<some_choice_backend_value>'){
g_form.setValue('<text_input_variable_backend_name>', 'some text');
} else if(choiceValue == '<some_choice_backend_value>'){
g_form.setValue('<text_input_variable_backend_name>', 'some text');
}
You can also try with switch cases instead of if-else.
If you just want to set the choice value to the text field, then utilize the below script.
var choiceValue = g_form.getValue('<choice_variable_backend_name>');
g_form.setValue('<text_input_variable_backend_name>', choiceValue);
// To set the lable of choice value, utilize the below statement.
//g_form.setValue('<text_input_variable_backend_name>', g_form.getOption('<choice_variable_backend_name>', newValue).text);
To map the text variable value to description, use map to field in variable configuration.