- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 01:13 AM
In catalog task , we have a field name called " Server name " and if this field name and cmdb table name is same ( comparison ), then have to update the variables in the same
example : Field in Task
Form CMDB record
If both are same , then need to update the variables values in to cmdb table record( Variables - which is available in the same catalog task )
Variables in task
Both are reference field in the cmdb table ( location and configuration country ) , how to do this
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 02:05 AM
Hi,
you need to write after update BR on sc_task with condition as below:
BR: current.request_item.cat_item == 'catalogItemSysId' && current.u_server_name != ''
Script below:
Note: Ensure you use valid catalog item sys_id; server name field; proper variable for device location
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', current.u_server_name);
gr.query();
if(gr.next()){
gr.location = current.request_item.variables.device_location;
gr.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 01:27 AM
Hi Sukran,
If you have a workflow for the catalog item, then add a activity called run script and include the below script.
var record = new GlideRecord('cmdb_ci');
record.addQuery('name', current.variables.server_name); //name of the variable in catalog item
record.query();
if (record.next()) {
//record.setWorkFlow(false); // add this step if needed to stop cascading business rules
record.location = current.variables.variable_name; // name of the variable where you update location
record.update();
}
Kindly mark my response helpful and correct, if this resolved your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 01:30 AM
Server name is a field in catalog task , not variables ... need to get value from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 01:54 AM
Hi Sukran,
Ok, you can try a After business rule to update the cmdb_ci table.
To query the cmdb_ci with the server name from catalog task. Try to write the business rule on sc_task table.
var record = new GlideRecord('cmdb_ci');
record.addQuery('name', current.server_name); //name of the field in catalog item
record.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2020 02:05 AM
Hi,
you need to write after update BR on sc_task with condition as below:
BR: current.request_item.cat_item == 'catalogItemSysId' && current.u_server_name != ''
Script below:
Note: Ensure you use valid catalog item sys_id; server name field; proper variable for device location
var gr = new GlideRecord('cmdb_ci');
gr.addQuery('name', current.u_server_name);
gr.query();
if(gr.next()){
gr.location = current.request_item.variables.device_location;
gr.update();
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader