We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Called script include using reference qualifier

GBS
Tera Contributor

called below script in a reference qualfier while calling passed a parameter but the value not getting pass script include function

 

Reference qualifier: javascript:newCIvalueretrieve().getCis(current.variables.name_of_application_service_you_want_to_map):

 

Script Include: var Civalueretrieve = Class.create();
initialize: function() {},

getCis: function(parentId) {

var parentIdValue "parentId;
gs.log("parentId sai testing" parentIdValue);

var relations = new GlideRecord('cmdb_rel_ci');

relations.addQuery("parent", parentIdValue);

relations.query();

var ciData [];

while (relations.next()) {

var cis new GlideRecord(cmdb_ci");
cis.addQuery("sys_id', relations.child.sys_id);

cis.query();

if (cis.next()) {

ciData.push(cis-getuniqueValue());
}
}
var strQuery new ArrayUtil().unique(ciData);

return "sys_idIN” + strQuery;
},

type: 'CIvalueretrieve
};

 

1 ACCEPTED SOLUTION

@GBS 

then in that list collector variable you should give variable attributes so that the ref qualifier works

ref_qual_elements=name_of_application_service_you_want_to_map

add that in variable attributes

AnkurBawiskar_0-1736770047027.png

 

Also don't use gs.log(). use gs.info()

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

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

View solution in original post

14 REPLIES 14

Hi Ankur,

 

I have similar kind of issue, where I have applied reference qualifier on List collector. And the variable type which I passed is reference.  The reference field value is passing as empty while calling the script include function.

I have a similar issue, where 

Please share on what variable type the ref qualifier is applied - List collector

Also share what's the variable type for "name_of_application"? - Reference

 

Where the value is not getting pass while calling the script include. 

 

@Ankur Bawiskar the ref qualifier is applied on the List collector variable type and the variable type of "name_of_application_service_you_want_to_map" is a Reference

@GBS 

then in that list collector variable you should give variable attributes so that the ref qualifier works

ref_qual_elements=name_of_application_service_you_want_to_map

add that in variable attributes

AnkurBawiskar_0-1736770047027.png

 

Also don't use gs.log(). use gs.info()

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

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

@Ankur Bawiskar 

Can we set default values to list collector field? based on the other reference field