Need to create a task manually via Workflow under the RITM . I have RITM created but unable to add the catalog tasks underneath that in servicenow

collfit
Giga Contributor

Need to create a task manually via Workflow under the RITM . I have RITM created but unable to add the catalog tasks underneath that in servicenow 

 

find_real_file.png

 

 

var tsk = new GlideRecord('sc_task');

tsk.initialize();

tsk.request_item = current.sys_id;

tsk.state = 1;

 

task.insert();

 

Please let me know if any additions  needed or do we have any other process ?

 

 

1 ACCEPTED SOLUTION

There are syntax errors. I corrected them. try this.

 

var tsk = new GlideRecord('sc_task');
//test
tsk.initialize();

//tsk.u_access_requested_for = current.variables.u_term_name;

// tsk.due_date = current.due_date;
//tsk.description = reqItem.sys_id;
//tsk.request_item = reqItem.sys_id;

tsk.request_item = workflow.scratchpad.reqItem;

tsk.state = 1;
tsk.approval.setDisplayValue('Approved');
tsk.assignment_group = "sys_id of GRP"; 

tsk.insert();


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

13 REPLIES 13

yes , i will change this to to TASK to TASK . But it is not even creating one task under that RITM . 

There are syntax errors. I corrected them. try this.

 

var tsk = new GlideRecord('sc_task');
//test
tsk.initialize();

//tsk.u_access_requested_for = current.variables.u_term_name;

// tsk.due_date = current.due_date;
//tsk.description = reqItem.sys_id;
//tsk.request_item = reqItem.sys_id;

tsk.request_item = workflow.scratchpad.reqItem;

tsk.state = 1;
tsk.approval.setDisplayValue('Approved');
tsk.assignment_group = "sys_id of GRP"; 

tsk.insert();


Please mark this response as correct or helpful if it assisted you with your question.

This helped me . Thanks . And in addition to this . Can we Just pull all the variables from the order guide to the manually created TASKS . Is there a way to this because i dont want to do via Maintain Items form . 

Woz
Tera Contributor

Use var gr = new GlideRecord('sc_req_item'); // to create a new record (RITM) on the request item list

 

more info here

 

https://www.servicenowguru.com/scripting/gliderecord-query-cheat-sheet/

 

Hope this helps