- 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-08-2020 07:46 AM
Thanks Ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 07:55 AM
You are welcome.
Regards
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-08-2020 08:10 AM
Hi Ankur,
Shouldn`t this be done on the workflow/flow before creating the sc_task record as this use case looks specific to the catalog item and sc_task table is used by other catalog items too ?
Please correct me if I am wrong.
Thanks,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 08:39 AM
Hi Rahul,
As per the question I assumed the field "u_server_name" will be updated by some Agent working on the catalog task; If that is the case then the workflow on RITM won't help. Hence after update BR on that table. This can also be handled using workflow run script once task is completed.
yes this can be achieved using Flow Designer with trigger as Field Updated.
If the server name is being populated during Catalog Task Creation itself; then the code to update the cmdb_ci record can be placed inside the Advanced Script section of Catalog Task Activity
Regards
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-08-2020 10:23 AM
Thanks Ankur!