Multiple SCTASK based on Quantity

Marco Pasqua
Tera Guru

Hi,

 

my requirement is create multiple SCTASK based on quantity value selected by requestor in the catalog form.

 

Can you suggest how should i implement this with flow designer?

 

thank you

3 REPLIES 3

johnfeist
Mega Sage
Mega Sage

Hi Marco,

Your question is light on details so I'll give a more general answer.  I think that the challenge you are facing is that unlike workflow where you can have multiple branches from a single node, flow designer is much more linear.  What that translates to is something like this.  If the item is requested, task A gets created.  If the quantity is greater than some level Task B gets created, etc.

 

In my experience you end up with several paths based on the quantity.  I'm assuming that any approvals are either given before the tasks are created or are created based on the number requested.  I would approach it by starting with a test for quantity >= highest number and assign the various tasks and approvals.  What you  want to make sure of is that you assign all the tasks without checking the Wait box.  That will create all the tasks at once.  Having done that you put a Wait For action where you check that all the tasks have been completed after all the Create Catalog Task actions.  You then have an Else If condition off of the check for maximum to check for the next level and repeat until all that is left is an Else where the quantity is at the lowest level.

 

If there is nothing else to do after the tasks are all completed, add an Update Record action at the end of each path to set State, Stage, etc. on the RITM record and terminate the patch with an End (found under logic). 

 

If there is a standardized set of actions that need to be taken for all quantities after the tasks are completed, you can create a subflow to do that and include that at the end of each path either instead of or in addition to the Update Record action.

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Marco Pasqua
Tera Guru

Hi,

you're right i was very light on details.

 

Suppose you have a catalog item where user can select how many pen drive he wants to order. He select 3. For some specific reason, client wants to have the following request structure on ServiceNow.

 

1- REQ

1- RITM

N-SCTASK (N=quantity selected by variables)

 

For this reason whatever the quantity is i need to create multiple sctask for the same REQ/RITM. Therefore the workflow must be dynamic and ready to create all the SCTASK the moment the RITM is approved. 


SCTASK can not be created one after another, but has to be there all at the same moment.

 

Thank you

Hi Marco,

 

I think that unless there are some constraints, that requirement could lead to a crazy number of tasks (what if someone orders hundreds).  Having said that, I think your only option is to build an action where you pass in the quantity ordered, the item and any other relevant data.  From there you will need to have a script action where you will loop through and have the script create the tasks.

 

I haven't had to do anything like that so I don't know if the flow will wait for all tasks to complete.  If it doesn't, you'll need to do something like this.  Add a column to sys_req_item with a name like All Tasks Complete.  Then create a BR on sc_task that will fire as part of task close to check if there are any more open tasks for that item.  If not the BR will set All Tasks Complete to true.  With that in place, you can have a Wait For action on the RITM to wait until All Tasks Complete == True. Depending on what else is needed, you can tailor the BR to be more specific but I think you get the approach.

 

The logic is similar to the way we have RITMs autoclose when all tasks and approvals have been completed. 

I know it sounds a bit cludgey but I'm not aware of any other way to do what you need.  At least the coding is pretty simple.

 

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster