How to check variable is present in Variable Editor or not?

nayanawadhiya1
Kilo Sage

Hey,

I need a help.

How to check variable is present in Variable Editor or not in Catalog Task?

But that field is in Service Catalog.

variable.PNG

1 ACCEPTED SOLUTION

Hey Robbie,




I resolved my Issue by trimming short description field from sc_task like this -





var fc = gr.variables.ssaw_name_subcontractors.getDisplayValue();


var sc = gr.variables.ssaw_name_subcontractor2.getDisplayValue();      


if(gr.short_description.indexOf(fc) != -1)


                                      {


                                      str=str+"<tr>"+"<td style='border: 1px solid black'>"+gr.variables.ssaw_name_subcontractors.getDisplayValue()+"</td>";


gs.log('FC:'+ gr.variables.ssaw_name_subcontractors.getDisplayValue());


}


else if(gr.short_description.indexOf(sc) != -1)


                                      {


                                              str=str+"<tr>"+"<td style='border: 1px solid black'>"+gr.variables.ssaw_name_subcontractor2.getDisplayValue()+"</td>";


gs.log('SC:'+ gr.variables.ssaw_name_subcontractor2.getDisplayValue());


                                      }


View solution in original post

5 REPLIES 5

Robbie
Kilo Patron
Kilo Patron

Hi Nayan,


There are a few attributes that enable a Catalog variables visibility throughout the tool which can be edited on the 'Visibility' tab when opening the variable.


However, in order for a variable to be seen in the Variable editor on the task form, ensure the 'Global' attribute is set to true. Its a hidden attribute.



See below:


find_real_file.png



Please mark correct and/or helpful by clicking on your post link (How to check variable is present in Variable Editor or not? ) to help close out open questions and also aid others with the same/similar questions.



Thanks,


Robbie


Robbie
Kilo Patron
Kilo Patron

Hi Nayan,


How did you go?



Please mark correct and/or helpful by clicking on your post link (How to check variable is present in Variable Editor or not? ) to help close out open questions and also aid others with the same/similar questions.



Thanks,


Robbie


I am trying to compare in scheduled script like this -



var fc = gr.variables.ssaw_name_subcontractors;


var sc = gr.variables.ssaw_name_subcontractor2;



if(fc != '' || fc!= 'undefined' || sc == 'undefined')


                                      {


                                      str=str+"<tr>"+"<td style='border: 1px solid black'>"+gr.variables.ssaw_name_subcontractors.getDisplayValue()+"</td>";


gs.log('FC:'+ gr.variables.ssaw_name_subcontractors.getDisplayValue());


}


if(sc != '' ||   sc!='undefined' || fc =='undefined')


                                      {


                                      str=str+"<tr>"+"<td style='border: 1px solid black'>"+gr.variables.ssaw_name_subcontractors.getDisplayValue()+"</td>";


gs.log('SC:'+ gr.variables.ssaw_name_subcontractor2.getDisplayValue());



                                      }



but the names came from Catalog Task like this and i dont want to show both names at same time because that variables is depend on Short_description -


1st.PNG


2nd.PNG


Robbie
Kilo Patron
Kilo Patron

Hi Nayan,


If I understand your question correctly, you're wanting to control whether a variable is displayed on a Catalog task (on the Variable Editor section) based on the Short Description? Is that correct?


For this you could create a UI policy script for example and leverage the set the display method - g_form.setDisplay(fieldname, true/false) to control this based on your chosen condition.



Thanks,


Robbie