- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 08:50 PM
I am trying to populate a catalog task that is generated from the workflow with the same assignment group of the previously closed task like the below screenshot.
The SCTASK0045000 is closed with a Assignment group - "Asset" then the next catalog task SCTASK0045037 that generates should automatically have the assignment group from the previously generated task - Asset.
The newly generated task should populate with the previous task assignment group.
I am not getting an idea on the approach, could someone help me with this.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 11:49 PM
Hi
Thanks for your trust in me. In this case, I took some extra time to drill out the tested and working solution just for you 🙂
The script I supplied for you above was untested and was a scaffolding in fact - so sorry, if it threw an error. The below script is well tested, and all my tests succeeded to what you are telling me. I created an example workflow to test it.
Here is the new script, which I tested (and I hope it works for you as well):
Note: If intentionally left in all of my comments I took during testing, so it can also act as some sort of lesson for you, as well.
// The next line can be uncommented to review the current value on the Scratchpad
// gs.info('Dirk-BEFORE:' + workflow.scratchpad.pre_task_sysid);
// Only update/set the Assignment Group, if there was a previous SC_TASK
// which means, that the scratchpad variable was set before
if (workflow.scratchpad.pre_task_sysid != '') {
// The next line can be uncommented to debug, that the scratchpad has a "sys_id" stored
// gs.info('Dirk: There is a previous SYS_ID on Scratchpad');
// Open the "PREVIOUS" SC_TASK to get the Assignment Group of that task
var grTask = new GlideRecord('sc_task');
grTask.addQuery('sys_id', workflow.scratchpad.pre_task_sysid);
grTask.query();
// If the record was found, then assigne that assignment group to the new
if (grTask.next()) {
// The next line can be uncommented to log, that the previous task was found
// gs.info('Dirk: Previous Task found!');
task.assignment_group = grTask.assignment_group;
}
}
// BEFORE calling "task.setNewGuid()", the field "task.sys_id" is EMPTY !!
// gs.info('Dirks Workflow sys_id of SC_TASK-1: ' + task.sys_id);
// This call does not return any value, as the "sys_id" of the "task" Record ist not set yet
// gs.info('Dirks Workflow sys_id of SC_TASK-2: ' + task.getUniqueValue());
// We can get the NEW "sys_id" of the "task", if we now call for one!
// Store the GUID of this SC_TASK for NEXT SC_TASK (for reference)
workflow.scratchpad.pre_task_sysid = '' + task.setNewGuid();
// For testing purposes, uncomment the following line to review this in the "System Log"
// gs.info('Dirk-AFTER:' + workflow.scratchpad.pre_task_sysid);
This was my test-workflow to find out if it works as expected. I made is look like the steps you have in your workflow:
In Action:
Closing the first task will create the next one, which will take the Assignement group from the previous one:
See, that the second task took the same Assignment group as the previous one:
Now, if I change the Assignment Group of the second task manually and close the second task:
The next task will take again the Assignment Group of the previous one:
So, from my understanding, it is exactly what you have been asking for. This should solve your requirement in detail.
I made the script above generic in that way, that you can just copy it in EACH "Catalog Task" Activity Script in your workflow. That's escactly what I did. SO, you do not need to care about "the first task" and "the next task" conditions - or something like that.
Just copy in the script in have fun.
Let me know if that answers your question and mark my answer as correct and helpful.
BR
Dirk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 09:07 PM
Hello kirthi,
You can do this by using script option in task activity.
Or using after before insert business rule you can use ,
var gr=new GlideRecord("sc_task");
gr.addQuery("request_item",current.sys_id);
gr.query();
if(gr.next())
{
var ass_grp=gr.getValue("assignment_group");
current.setValue("assignment_group",ass_grp);
}
Hope this will helps.
Kindly mark an answer as correct and helpful if it will resolve your query.
Regards,
Akshata

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2020 09:29 PM
Hello kirthi,
You can do this by using before insert BR on [sc_task] table,
var gr = new GlideRecord("sc_task");
gr.addQuery("request_item", current.request_item);
gr.query();
if (gr.next()) {
if(gr.state=="close complete value")
{
current.assignment_group=gr.assignment_group;
}
}
Hope this will helps.
Kindly mark an answer as correct and helpful if it will resolve your query.
Regards,
Akshata
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 08:29 AM
Hi Akshata,
This script worked and its copying over the assignment group. I made some changes on when should it run and its working for only one catalog item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2020 08:54 AM
Hi kirthi,
Thank you for marking the answer as helpful and for updating on the same. I am glad to help you.
Thanks & Regards,
Akshata