- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 01:07 AM
I want to make a field mandatory and add certain options to the string field based on a selection of a reference field on the form.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 01:26 AM
Hi Samyukta,
I assume that you want to make a field mandatory and add options to it based on the selection of a variable on the service catalog. This can be done using -
1. First write a client script on the Service Catalog - Type-> OnLoad , Applies on Catalog Item View and Isolate Script Set to False
function onLoad() {
this.form_g_form=g_form;
}
Then using this form_g_form object, write a client script inside multi-row variable set -
var main_form_variable_value=this.form_g_form.getValue("main_form_variable_name");
if(main_form_variable_value=="value"){
g_form.addOption('var_1', 'choice_1', 'Choice1', 1);
g_form.addOption('var_1', 'choice_2', 'Choice2', 2);
g_form.setMandatory("var_1",true);
}
Please like and Mark as Correct if this solves your issue

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 01:19 AM
Hi
Please go through the below article that will give you some directions.
http://rubenferrero.com/servicenow/multi-row-variable-set-form-communication/
Please mark this helpful/correct, if applicable.
Regards,
Muhammad
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 01:26 AM
Hi Samyukta,
I assume that you want to make a field mandatory and add options to it based on the selection of a variable on the service catalog. This can be done using -
1. First write a client script on the Service Catalog - Type-> OnLoad , Applies on Catalog Item View and Isolate Script Set to False
function onLoad() {
this.form_g_form=g_form;
}
Then using this form_g_form object, write a client script inside multi-row variable set -
var main_form_variable_value=this.form_g_form.getValue("main_form_variable_name");
if(main_form_variable_value=="value"){
g_form.addOption('var_1', 'choice_1', 'Choice1', 1);
g_form.addOption('var_1', 'choice_2', 'Choice2', 2);
g_form.setMandatory("var_1",true);
}
Please like and Mark as Correct if this solves your issue