Variable type from ritm script

Varun30
Giga Expert

I need to populate variable values to ritm description. I need to skip populating variables of type html. Is there a way to identify the variable type for an existing ritm ? Something like current.variables.variable_name.type?

7 REPLIES 7

Manmohan K
Tera Sage

Hi @Varun30 

 

You can run below script to get the variable type in your request item

 

var ReqItem = new GlideRecord('sc_item_option_mtom');


ReqItem.addQuery('request_item','5a21618e9757e910994b30d3f153af64');  // add RITM sys_id


ReqItem.query();


while(ReqItem.next())


{

gs.log(ReqItem.sc_item_option.item_option_new.type.getDisplayValue());


}

 

Thanks for the reply. This will give me list of all variable types in ritm. I am looking for something like you pass the variable in ritm to script include and it returns the variable type. Basically this format :

variable_name : variable_type

@Varun30 

 

Then just modify like below

 

var ReqItem = new GlideRecord('sc_item_option_mtom');


ReqItem.addQuery('request_item','5a21618e9757e910994b30d3f153af64');  //pass ritm sys_id


ReqItem.query();


while(ReqItem.next())


{

if(ReqItem.sc_item_option.item_option_new.name=='photoshop'){  //pass variable backend name

return ReqItem.sc_item_option.item_option_new.type.getDisplayValue();


}}

Thats the thing. I don't want to limit it to one catalog item. In your example, I don't know the 'photoshop' variable type. I need to iterate through all variables in ritm and identify html variables.