UI Policy for multi row variable set

sreejith05
Giga Expert

Hi Team,

I am using a multi row variable set in a form as below. "Item name" is a lookup select box variable and i wanted to set the "Location to deliver"  field mandatory in the form if the item name is Other.

 

find_real_file.png

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Since it looks like you are using Service Portal, first create an onLoad Catalog Client Script on the Record Producer/Catalog Item (not within the MRVS) so that you have access to variables on the Catalog Item from a script within the MRVS.

function onLoad() {
	if (this) {//we only need to do this for Service Portal
		//We need to make the g_form object for the parent item available from the MRVS window
		this.cat_g_form = g_form;
	}
}

Next create an onChange Catalog Client Script within the MRVS when the Item Name variable changes.  This script will work in both the native UI and Service Portal.

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

	if(newValue == 'other'){//replace with the correct value
		if(this){//Service Portal method
			this.cat_g_form.setMandatory('location_to_deliver', true);//replace with the correct variable name
		}
		else{//native UI method
			parent.g_form.setMandatory('location_to_deliver', true);
		}
	}
}

View solution in original post

2 REPLIES 2

Anil Lande
Kilo Patron

Hi,

You can create a onChange client script in your multirow variable set onChange of Item Name variable :

use OnChange script as below:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
if(newvalue == 'other'){
	if(parent.g_form){
        parent.g_form.setMandatory('location_to_deliver', true);
    }
}
}

for the same approach please check below link:

https://community.servicenow.com/community?id=community_question&sys_id=37c35df8dbb6d850fb115583ca96...

 

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Brad Bowman
Kilo Patron
Kilo Patron

Since it looks like you are using Service Portal, first create an onLoad Catalog Client Script on the Record Producer/Catalog Item (not within the MRVS) so that you have access to variables on the Catalog Item from a script within the MRVS.

function onLoad() {
	if (this) {//we only need to do this for Service Portal
		//We need to make the g_form object for the parent item available from the MRVS window
		this.cat_g_form = g_form;
	}
}

Next create an onChange Catalog Client Script within the MRVS when the Item Name variable changes.  This script will work in both the native UI and Service Portal.

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }

	if(newValue == 'other'){//replace with the correct value
		if(this){//Service Portal method
			this.cat_g_form.setMandatory('location_to_deliver', true);//replace with the correct variable name
		}
		else{//native UI method
			parent.g_form.setMandatory('location_to_deliver', true);
		}
	}
}