- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 09:08 PM
Hi,
There's a mandatory field value I need to capture from catalog task ticket when close, after that I need that field value to store back into the parent RITM ticket (which is the current) in order to write that value into a table, how can I copy the value of this same field from TASK to RITM in the workflow?
I added this line into the 'Create Task' stage and obviously it didn't work, after the TASK ticket is closed, can still see this cmdb_ci field on the RITM field as blank and still mandatory.
Regards,
Simon.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 10:53 PM
Hi,
Please refer below thread, it might helpful to you.
Mark it correct and helpful.
Thanks
Bhagyashri Sorte.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 09:41 PM
Hi Simon,
you need to get the task for this RITM in the run script and then create record into your custom table based on the values
I could see you are using the values from RITM since you are having current object
Please explain are you updating the custom field u_affected_contact and the cmdb_ci field on RITM once task is closed?
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
‎09-07-2020 09:55 PM
yes, you have to run the query in order to check if you are updating for the particular requested item only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 09:58 PM
Am I still doing something wrong? my hardware inventory table still written the cmdb_ci (which is 'service tag' field) as (empty).
var get_ci = new GlideRecord('sc_task');
get_ci.addEncodedQuery("request_item", current.getValue("sys_id"));
get_ci.query();
if (get_ci.next()) {
current.cmdb_ci = get_ci.cmdb_ci;
current.update();
}
var upd_inv= new GlideRecord("u_hardware_inventory");
upd_inv.addQuery('u_service_tag', current.cmdb_ci);
upd_inv.query();
var createInv = true;
while(upd_inv.next())
{
upd_inv.u_sys_user = current.u_affected_contact.getDisplayValue();
upd_inv.u_emp_id = current.u_affected_contact.employee_number.getDisplayValue();
upd_inv.u_location = current.u_affected_contact.location.getDisplayValue();
upd_inv.u_emp_status = current.u_affected_contact.active.getDisplayValue();
upd_inv.u_monitor = 2;
upd_inv.update();
createInv = false;
}
if (createInv)
{
var gr = new GlideRecord('u_hardware_inventory');
gr.initialize();
gr.u_service_tag = current.cmdb_ci.getDisplayValue();
gr.u_sys_user = current.u_affected_contact.getDisplayValue();
gr.u_emp_id = current.u_affected_contact.employee_number.getDisplayValue();
gr.u_location = current.u_affected_contact.location.getDisplayValue();
gr.u_emp_status = current.u_affected_contact.active.getDisplayValue();
gr.u_monitor = 2;
gr.insert();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 10:06 PM
u_service_tag is a reference field? If yes, then try as below
gr.u_service_tag = current.cmdb_ci;
Or try
gr.u_service_tag = current.configuration_item;
On the RITM level Configuration Item field name is configuation_item, not cmdb_ci so please make sure you are using the right name throughout the script.
Also, place a log gs.info("SIMON - "+ current.configuration_item); to check if the value is coming from the RITM table.
All other values are inserting as expected?
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2020 10:09 PM
updated the above comment!
Muhammad