Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to query multiple tables via one GlideRecord

amitroy
Tera Contributor

Hi All,

I have a requirement where a custom field 'Row/Rack location' which extends from the 'cmdb_ci' table needs to be updated on 26 different classes. Currently a Transform map is configured on one target table - cmdb_ci_hardware where it updates the row/rack location field to only this target table.

 

The requirement is to update around 26 different classes. There is no such mapping exists on those 26 tables.

Is there a way to include more classes on 1 transform map? Can we built a scrip (OnBefore) to customize the mapping?

 

 

 

1 ACCEPTED SOLUTION

Joshwa Antony S
Mega Guru

Yes you can. Try it out.

Create a property and store values (tables/classes)

example: incident,problem,change,sc_req_item // mention your classes here

var table = gs.getProperty("YOURPROPERTYNAME HERE").split(","); //this convert the comma separate string to array 

for(var i=0; i<table.length; i++){ // this will iterate based on number of table

var gr = new GlideRecord(table[i]);
gr.newRecord();
gr.short_description = 'TEST';
gr.insert();

}

Regards,

JAS

View solution in original post

8 REPLIES 8

amitroy
Tera Contributor

Can I use a system property instead or something like this? Creating a table or something?

amitroy
Tera Contributor

Can I also refer a table in the OnBefore Transform script?

 

Joshwa Antony S
Mega Guru

Yes you can. Try it out.

Create a property and store values (tables/classes)

example: incident,problem,change,sc_req_item // mention your classes here

var table = gs.getProperty("YOURPROPERTYNAME HERE").split(","); //this convert the comma separate string to array 

for(var i=0; i<table.length; i++){ // this will iterate based on number of table

var gr = new GlideRecord(table[i]);
gr.newRecord();
gr.short_description = 'TEST';
gr.insert();

}

Regards,

JAS

jyoti5
Tera Contributor
It is working.. thank you