- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 08:31 PM
I have a use case, where I need to fetch the task number and task sys_id at create task workflow step to send these values to REST Message - POST method.
Any suggestion how I can get these values at the create task workflow step ?
I have created this workflow for a service catalog item and after approval stage I am creating a fulfillment task.
Any clue to get this done would be appreciated.
Regards,
Khalid
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 10:48 PM
Hi Khalid,
task sys_id can be obtained in the catalog task advanced activity using this
task.setNewGuid();
for getting task number workaround here
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 09:05 PM
Hi Khalid,
You can user GlideRecord query to get sys_id and numbe of thask you have created for your RITM.
var taskGR = new GlideRecord('sc_task');
taskGR.addQuery('request_item',current.sys_id);
taskGR.addQuery('short_description','Your task short description'); //additional filter condition to get your task record
taskGR.query();
if(taskGR.next()){
//get required values from taskGR.fieldname
}
Please mark correct answer and helpful if this help to resolve your issue.
Thanks,
Anil Lande
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 09:14 PM
Hi Khalid,
Also an alternative to get the task sys_id and number in same activity is to create a catalog task using "Run Script" activity instead "Create Catalog Task" activity.
In run script activity you can use Glide Record API to insert task and once task is created you get the sys_id of same record as return value. In same script you can Glide to sc_task table to get record using sys_id and get all other parameters.
Also in same script you can call REST API's.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 10:41 PM
Hi Anil,
I already tried to fetch the required values using the Glide Record API in Create Catalog Task activity -> Advanced script but no luck.
Used the following script:
var gr = new GlideRecord('sc_task');
gr.addQuery('request_item.number',current.number);
gr.query();
gr.next();
var task_number = gr.number;
var task_sysid = gr.sys_id;
Regards,
Khalid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2021 10:48 PM
Hi Khalid,
task sys_id can be obtained in the catalog task advanced activity using this
task.setNewGuid();
for getting task number workaround here
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader