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

Ankur Bawiskar
Tera Patron
Tera Patron

@tushar_ghadage 

so you have 2 variables within MRVS and 1 variable outside the MRVS?

1) If yes then you can access the outside variable value in MRVS onLoad catalog client script and remove the options you don't want

check my blog on how to access the outside variable in MRVS client script

Access value of catalog item variable within MRVS client script 

sharing here as well

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

2) Also you will require 1 catalog UI policy which Applies on Variable set (MRVS) on "Select choice" so that when value is on prem you show the other MRVS variable using Catalog UI policy action

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

Hi @Ankur Bawiskar  ,

thanks for the reply, so I have one on load catalog script in MRVS mentioned below: 

where I making field called select choice visible when TYPE B is selected in field called ' this is regarding': 

function onLoad() {
   //Type appropriate comment here, and begin script below
   
  var applicationType = g_service_catalog.parent.getValue("this_is_regarding");


    function toggleSelectChoiceVisibility() {
    var thisIsRegarding = g_form.getValue('select_choice');
   

    if (thisIsRegarding == 'Type B') {
   
        g_form.setDisplayTableField('your_mrvs_variable_set_name', 'select_choice', true);
    } else {
       
        g_form.setDisplayTableField('your_mrvs_variable_set_name', 'select_choice', false);
    }
}
}
its not working when i test it : 
when type B is selected then only select choice field in MRVS should get visible
Screenshot (112).png
its getting visible for the other types as well given below : for TYPE A 
Screenshot (113).png
below is the on load script in MRVS :
Screenshot (114).png



 

@tushar_ghadage 

you are using wrong scripts

why did you use this function toggleSelectChoiceVisibility?

this function is not valid setDisplayTableField

I believe I have already shared a working solution and approach, link for the article already shared above.

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

Screenshot (116).png

this is updated script 

but it's not working.