Need to create record in "task_cmdb_ci_service" table with the listcollector values
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2022 10:27 PM
Hello Community Leaders,
We have one List collector variable which is refering to cmdb_ci table to select multiple ci's in one of catalog item. when user select CI's and submit, The change record should be created & also "task_cmdb_ci_service" should be created with the values of CI's which i selected when request was submitted & with the change number.
I have created workflow for the same.
to create change record i am usign create task activity & to create record in "task_cmdb_ci_service" table i am using run script activity with below script.
var gr = new GlideRecord('task_cmdb_ci_service');
gr.initialize();
gr.cmdb_ci_service = current.variables.ci;
gr.task = workflow.scratchpad.number;// this number is from "create task activity"
gr.insert();
But it is not working as expected. Please help me here.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 03:47 AM
Hi,
are you sure the workflow scratchpad variable has sys_id in it
you can use this to assign the workflow scratchpad
workflow.scratchpad.a = task.setNewGuid();
Updates script
var arr = current.variables.ci.toString().split(',');
for(var i=0;i<arr.length;i++){
var gr = new GlideRecord('task_cmdb_ci_service');
gr.initialize();
gr.cmdb_ci_service = arr[i];
gr.setValue('task',workflow.scratchpad.a);
gr.insert();
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader