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

Mike Patel
Tera Sage

var tsk = new GlideRecord('sc_task');

tsk.initialize();

tsk.request_item = current.sys_id;

tsk.state = 1;

 

task.insert(); 

needs to be tsk

 

you can also add tsk.parent = current.sys_id

Sharique Azim
Kilo Sage

Hi,

 

This would be silly to say, but did you check out the workflow? And did you search for task in the core section?

Creating task from blocks should be preferred, else the answer given by Mike is absolutely correct.

Hi All,

Sorry for the confusion. 

What we are trying to accomplish here is the following

We understand you can create a task using the current.sys_id. However we are creating a new RITM within the workflow and we need the tasks new created to be under that new RITM. and since the current.sys_id will be the original RITM which is not the new one. We are wondering how we can link the new created Task with the new RITM created within the workflow

This will help

https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideappCalculationHelper/concept/GlideappCalcHelperAPI.html