Trigger Workflow Based on Catalog Item Selection in Order Guide

jmiskey
Kilo Sage

I have kind of a tricky situation which I am trying to figure out how to approach.

We have an Order Guide with three Catalog Items to choose from.  The Order Guide itself does not have a workflow attached to it.  2 of the 3 Catalog Items in my Order Guide do.  They are pretty straight forward, creating a single RITM, so those Workflows run off of sc_req_item and are available to be selected from the Workflow field on the Catalog Item.

However, my third one is a bit trickier.  It needs to create multiple RITMs, so the Workflow needs to run against sc_request so we can create multiple RITMs within that workflow.  However, when we create a workflow based on sc_request, it is not available to be selected from the Workflow field on the Catalog Item.  

I see from Workflow -> Properties -> Conditions, I could try to set a condition of which the workflow should run.  We have done this before, based on the Order Guide value.  However, that Order Guide was pretty straight forward and didn't have three different Catalog Items, each with their own workflow, listed underneath it.  So the Order Guide field,in and of itself, does not contain enough information regarding when the workflow should be called.  It is dependent upon the Catalog Item selected in the Order Guide (have a variable for that selection).

So, how can I do this?  How can I set up the Workflow for this third option to run off of sc_request and get it to be called when that third option is selected?

Thanks

1 ACCEPTED SOLUTION

This is what I have used to trigger new items from an initial item and added to the same request.

var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request,<sysID of the item>, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);

My use case:

We had an item that collected multiple share file locations, but needed individual approvals for each location.  My setup was an initial item that runs a script with this code in it to generate the individual items under the same REQ.  The original item closes automatically after the fact, so one 'item' spawns x number of individual items (dependent upon how many share file locations they request), all on the same REQ.

 

https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=GlideappCalcHelperAPI

View solution in original post

35 REPLIES 35

I don't think you can do a workflow from sc_request so I'm saying you need to create a workflow that will script the ordering of items you need and they will then have their own distinct workflows.

You can (we actually have a handful that do), but the method that we used before won't work here.  Basically, we used the Conditions property on the workflow to tell it to run whenever the Order Guide field is a certain value.

So trying to understand the method that you are proposing, are you saying to have a single workflow (which runs off off sc_req_item) that would submit new requests for the other RITMs?  I didn't think it was possible to create new RITMs from inside a sc_req_item workflow, and have the new RITMs run on their own workflows, but all be under the same Request (apologies if I am not understanding your suggestion completely).

Maybe what I need to do is set it up so my Order Guide calls a workflow which runs off of sc_request (using the methodology I used before), and based on my Catalog Item selection, create the various RITMs, and have each Catalog Item have its own workflow based on sc_req_item.  So the creation of multiple RITMs would happen at that level, instead of deeper in.  I would just need to make sure that I pass all the proper values to each RITM when creating it.

Does that sound like a possible, reasonable approach?

I'm not 100% sure I never used an order guide.  I did however have a new hire workflow that would spawn a new request using the method I suggested above if certain criteria were met.  All my other workflow just spawned multiple tasks for different things if needed.

This is what I have used to trigger new items from an initial item and added to the same request.

var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request,<sysID of the item>, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);

My use case:

We had an item that collected multiple share file locations, but needed individual approvals for each location.  My setup was an initial item that runs a script with this code in it to generate the individual items under the same REQ.  The original item closes automatically after the fact, so one 'item' spawns x number of individual items (dependent upon how many share file locations they request), all on the same REQ.

 

https://developer.servicenow.com/app.do#!/api_doc?v=jakarta&id=GlideappCalcHelperAPI

So, would this create separate RITMs, under the initial request, each with their own workflow?

If so, then where exactly does this script go?

Is your first RITM really just a "dummy" one to hold all the data, and the create all the other ones (if which case there would be two separate workflows)?

I think this may be on the right track for me, I am just trying to understand how it all comes together.

Thanks.