Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to access main form data into Multi row Variable Set

Samyunkta Seth
Kilo Contributor

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. 

1 ACCEPTED SOLUTION

Anurag15
Giga Expert

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

View solution in original post

2 REPLIES 2

MrMuhammad
Giga Sage

Hi @Samyunkta Seth,

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 

Regards,
Muhammad

Anurag15
Giga Expert

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