- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 07:01 AM
Good morning, everyone.
I am developing a workflow that works with the triggering of Catalog Tasks after an approval in RITM. It is necessary that the requester receives a message that the SCTASK was created right after the approval, and that this message carries the task number (SCTASKXXXXX).
How can i do this? I'm trying but the task number at the message is undefined
workflow.scratchpad.task_number = task.number;
var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery('active=true^request_item=' + current.getValue('sys_id'));
grTask.addEncodedQuery('number=' + workflow.scratchpad.task_number);
grTask.orderBy('sys_updated_on');
grTask.setLimit(1);
grTask.query();
while (grTask.next()) {
var tarefa = grTask.number.getValue();
}
Here is the script I've used inside the task activity
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 07:50 AM
Hello @Reinaldo Vieira
In your screenshot you do not have approval activity, but task activity right after begin. even in this case or if there is approval before task, you can have two transitions from approval/begin(in screenshot), one directly to task creation, then second one add 5-10 seconds delay, then after delay configure an event trigger. in the event trigger activity, for parameter 1 you can write script as below to get SCTASK (for the current RITM last created SCTASK) and pass number. Now configure the notification on the event and task number can be read from event.
var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery('active=true^request_item=' + current.getValue('sys_id'));
grTask.orderByDesc('sys_updated_on');
grTask.setLimit(1);
grTask.query();
if (grTask.next()) {
return grTask.number.toString();
}
Thank you,
Ali
Thank you,
Ali

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 07:50 AM
Hello @Reinaldo Vieira
In your screenshot you do not have approval activity, but task activity right after begin. even in this case or if there is approval before task, you can have two transitions from approval/begin(in screenshot), one directly to task creation, then second one add 5-10 seconds delay, then after delay configure an event trigger. in the event trigger activity, for parameter 1 you can write script as below to get SCTASK (for the current RITM last created SCTASK) and pass number. Now configure the notification on the event and task number can be read from event.
var grTask = new GlideRecord('sc_task');
grTask.addEncodedQuery('active=true^request_item=' + current.getValue('sys_id'));
grTask.orderByDesc('sys_updated_on');
grTask.setLimit(1);
grTask.query();
if (grTask.next()) {
return grTask.number.toString();
}
Thank you,
Ali
Thank you,
Ali