- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 06:59 AM
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
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 ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 10:27 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 07:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 07:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 07:31 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2018 08:09 AM
This will help
https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideappCalculationHelper/concept/GlideappCalcHelperAPI.html