Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

set visible in variable set

tushar_ghadage
Tera Contributor

Hi Everyone, 

I have a requirement where on the catalog item, 

there are two custom fields in multi row variable set called select choice and application tag -

 

when a Type B is selected in choice field on the catalog form from choice field

field in the variable set select choice should be visible with the choice azure and on prem.

and only when on prem is selected another field called application tag should be visible (in variable set). 

 

I am new to variable sets can anyone help me out here please.

how shall I achieve this?

 

thanks!!

 

24 REPLIES 24

@tushar_ghadage 

Your original requirement was different

But if you want to hide the variable within MRVS based on outside variable value then do this

Ensure you give correct choice value to compare and correct variable name

function onLoad() {
    //Type appropriate comment here, and begin script below

    var applicationType = g_service_catalog.parent.getValue("this_is_regarding");

    if (applicationType == 'type B') // give the choice value to compare
        g_form.setDisplay('selectChoiceVariableName', false);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

no actually this is req 

I want to hide the variable inside the variable set depending on the variable outside of the variable set.

have tried with same script but still same issue its showing for every choice field.

given below :

Screenshot (118).pngScreenshot (119).png

backend name for choice field is 'select_choice'

Screenshot (120).png

@tushar_ghadage 

what came in alert? share that

function onLoad() {
    //Type appropriate comment here, and begin script below

    var applicationType = g_service_catalog.parent.getValue("this_is_regarding");
	alert('applicationType' + applicationType);

    if (applicationType == 'type B') // give the choice value to compare
        g_form.setDisplay('selec_choice', false);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

sure , 

 

Screenshot (121).pngScreenshot (122).pngScreenshot (123).png

Hi @tushar_ghadage ,

 

function onLoad() {
    //Type appropriate comment here, and begin script below

    var applicationType = g_service_catalog.parent.getValue("this_is_regarding");
	alert('applicationType' + applicationType);

    if (applicationType == 'type_b') // give the choice value to compare
        g_form.setDisplay('selec_choice', false);
}

check the backend value of the Type B choice and update it in the if condition if needed 

 

 

I have just corrected choice value based on your screenshot

 

addition to @Ankur Bawiskar's post

accept his post a as a solution and give a like to mine

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya