The CreatorCon Call for Content is officially open! Get started here.

Need help to make field mandatory in multirow variable set

sunil7
Giga Expert

Hi Everyone , I have a requirement on catalog item , we have two variable and a multirow variable set(Test1) on catalog item. Our requirement is when we select 1 in first variable (Copier paper) and 2 in second variable (Pens) then Field1 inside multirow variable set should become mandatory. Please see screenshot below

find_real_file.png

 

find_real_file.png

15 REPLIES 15

Sumit Maniktal1
Tera Expert

You should refer this

https://docs.servicenow.com/bundle/rome-application-development/page/app-store/dev_portal/API_reference/g_service_catalog/concept/g_service_catalogClientAPI.html

Try putting in a client script onLoad or onChange as per you need & check the parent variable value using below

g_service_catalog.parent.getValue("your_variable")
 

Then make the variable set variables mandatory as reuired

Hi Sumit,

 

Could you please share the screen shot how to full fill the requirement

 

is both variable sets are MRVS  or  (one single row another one MRVS)

 

 

if one is single row  and another one MRVS  then it is working?

Hitoshi Ozawa
Giga Sage
Giga Sage

I just created variables names "copier_paper_reams" and "pens_box_of_10" on the form.

Created variable sets with fields "field1" and "field2".

Created client script in variable set.

function onLoad() {
    try {
        var copier = parent.g_form.getValue('copier_paper_reams');
        var pens = parent.g_form.getValue('pens_box_of_10');
        if (copier == 1 && pens == 2) {
			g_form.setMandatory('field1', true);
		}
    } catch (e) {
        alert(e.message);
    }
}

find_real_file.png

Execution result:

1. When copier paper (reams) = 1 and Pens (box of 10) = 1

find_real_file.png

2. When copier paper (reams) = 1 and Pens (box of 10) = 2

find_real_file.png

 

Hi Hitoshi, 

What if these variables copier_paper_reams and pens_box_of_10 are in different variable set on same catalog then how access them?

I see that this has already been made into a new question.

https://community.servicenow.com/community?id=community_question&sys_id=71178fa9dbddc550fd6325091396...

Will assume that my reply here has answered the question here. Will therefore reply in the new question thread.