Dynamic Catalog Task Creation within RITM workflow

Harry Campbell2
Mega Guru

Hello Everyone,

I'm not sure if what I'm asking is even possible.

I want to create multiple tasks based on selections in the request item. This is for a 'User Leaving' request.

The requestor will select from a list of applications (Checkboxes on the catalog item).

I want to create a catalog task for each of the applications selected. We do currently do this using a switch and multiple 'Catalog Task' activities. My problem is that the list of applications is constantly changing and I dont want to spend my time updating the workflow, adding conditions and catalog tasks. I want it to be dynamic so when an application is added to the list.... the workflow will not need to be touched.

I'm open to all suggestions

Thanks

Harry

1 ACCEPTED SOLUTION

Hello,



Great! Glad I could help.



Im not sure how I would script the wait for condition to wait for the tasks to complete. How would I go about this?


Simplest tricks are the best tricks, I say. Simply run a GlideRecord query in the wait for condition script that looks for all records in the sc_task table whose parent is "current.getValue('sys_id')" (the sys_id of the RITM) and see if any of them are still open.


In fact, you can do that with a single query if you do something like this...



var openStateValues = []; //Add the integer values for all non-closed states here. You could also do the opposite and change the "IN" to "NOTIN" below.


var gr = new GlideRecord('sc_task');


gr.addQuery('parent', current.getValue('sys_id'));


gr.addQuery('state', 'IN', openStateValues);


gr.query();


answer = gr.hasNext();



Then set up an "After" BR on the sc_task table that'll run on any record where (with "show related fields" turned on in the business rule condition picker) parent.cat_item is (the catalog item you're referring to) and then "state, changes to, [one of the closed states]". Then have it simply do something like....



var parentgr = parent.getRefRecord();


parentgr.work_notes = current.getValue('number') + ' closed.';


parentgr.update(); //This will kick the workflow, triggering the re-evaluation of the condition.



Regarding the list collector, yes, you can auto-pop some values. Just push in an array or, if it's being finicky, a comma-separated string (just call .toString() on an array if you need to) of sys_IDs.



Don't forget to mark my answers as correct/helpful if I was able to help you out. 🙂 Thanks mate


View solution in original post

7 REPLIES 7

Sorry Timothy, one more question then I will leave you alone. Any idea how I can pass the variables from the RITM to the TASK?


Hi,



I have a similar requirement...



How did you script the sc_task record out of interest


brycefraser
Giga Contributor

Hi Harry,



One way to do this is to add a field to the applications list to store the resolver group for that particular application.



Then in the workflow for the catalog item, pull the list of applications and create catalog tasks using that list.