After approving the case, hr task should assign to same approver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:13 AM
Hi All,
I have a "CASE" which is assigning to a GROUP and any member in the group can approve the case, Now I need to assign a "TASK (HR Task)" to the same approver who approved the CASE earlier.
I have used the Create Task activity and used the Advanced scripting and written the below script and it is not waiting for completion of task and not triggering the task assigned to same approver.
Please suggest
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.sys_id);
gr.query();
if(gr.next())
{
task.assigned_to = gr.approver.name;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:51 AM
your script to assign user is wrong
update as this
are you using workflow for creating task? if yes then there is Wait for completion checkbox on Create Task activity
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('document_id', current.sys_id).addOrCondition('sysapproval', current.sys_id);
gr.query();
if(gr.next())
{
task.assigned_to = gr.approver;
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2023 04:31 AM
Hi Ankur,
Thanks for your reply.
It did work with below script.
var gr=new GlideRecord('sysapproval_approver');
gr.addEncodedQuery('sysapproval='+current.sys_id+'^state=approved');
gr.query();
if(gr.next())
{
task.assigned_to= gr.approver;
}