Access Type of Catalog Variable in Script

Prathamjeet Sin
Tera Contributor

Hi there, 

So I am currently trying to access the type of catalog variable but had no luck so far. 
Specifically I am trying to see if the variable is either lookup variable or not. 

I have tried multiple versions like this:

current.variables.project_name.type.getDisplayValue();
current.variables.project_name.type;

 Please let me know if there is a way to access the type. Thanks

3 REPLIES 3

Basheer
Mega Sage

Hi @Prathamjeet Sin 

I think you need to use alert(typeof(g_form.variables.project_name));

typeof() is the syntax to findout the type.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

panda1
Kilo Guru

You can query in the variable(item_option_new) table

var rec = new GlideRecord('item_option_new');
rec.addQuery('name','project_name');
rec.addQuery('cat_item','your item');
rec.query();
rec.next();
var type = rec.type;

 

Prince Arora
Tera Sage
Tera Sage

@Prathamjeet Sin ,

Please try this code and let me know if it works for you!

var mtom = new GlideRecord('sc_item_option_mtom');

mtom.addQuery('request_item',current.sys_id);// sys_id of sc_req_item record

mtom.query();

while(mtom.next()) {

gs.info("type of variables  : " + mtom.sc_item_option.item_option_new.type.getDisplayValue());

}