Need to create record in "task_cmdb_ci_service" table with the listcollector values

Vinay49
Tera Expert

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. 

find_real_file.png

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

6 REPLIES 6

Script below which is used in creat task activity

find_real_file.png

This is working fine & change request has also created

 

 

script below which is used in run script activity

find_real_file.png

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader