How to create a Switch Statement in the workflow that acts on a custom field across all ordered Catalog items.

willkara
Kilo Contributor

So we have a number of Catalog items that are order-able. They can range from Windows/Linux servers to database servers ...etc.

We've successfully created them in the catalog and are starting to create their forms and create the workflow for them. I was hoping to have a single workflow for all of the items that follows a single idea. Please see the image below.

WorkflowIdea.png

Each catalog item has a field that is hard-coded into it, a Service Identifier. We don't have it as a choice field or anything like that, just a simple Text field that we set a default value into and make it ReadOnly.

I'd like to create a Switch/Case statement that allows me to put in a condition for each separate identifier. I'm able to create the Switch statement now, but it makes me select a Service Identifier field on a specific Catalog Item.

serviceIden.PNG

Is there a way to make it possible to select the Service Identifier field from EACH item and create the Switch/Case statement for that? I could simply add a condition on the Switch/Case but I'm still left with the Always action. Something like this:

switch serviceIdentifier:

        case "this one":

                  do blah;

        case "that one"

                  do blah2;

- Will

It's not an Out-Of-The-Box field. It's a field that we have put in ourselves. Message was edited by: William Karavites

1 ACCEPTED SOLUTION

Ok, so if your user is to have no interaction with this field, then why make it a variable in the first place?
Why not just do evaluations in the workflow that ask what Catalog Item it is and branch logic from there (using IFs or Runscript)


View solution in original post

11 REPLIES 11

I suspect that's your issue.   System thinks its three separate variables.   They may have the same name, but they all have different sys_id's which makes them as different from a system perspective as peanut-butter is from corduroy.


Gotcha, I'll put it into a variable set and see what happens. Would this require me to put all of options into a Choice List instead of a regular text-box?


I understand the idea/reason to add it to a Variable Set. What I don't get is how we'd then set the default values for each item. I added it to some items, but you can't set the default value on a per-item basis then.



The user shouldn't be selecting a value for it. We just need the value to be pre-selected for each item. Then in the workflow, we can go over the values with a switch/case.



I just added a Switch/Case block to the workflow and the only option I see is still only Always. I don't see any of the options.


Ok, so if your user is to have no interaction with this field, then why make it a variable in the first place?
Why not just do evaluations in the workflow that ask what Catalog Item it is and branch logic from there (using IFs or Runscript)


UPDATE:



I was able to get at least ONE condition working in the "if activity"! I'm still trying to figure out how to get an if/else if/else if.... or Switch statement working. No matter what I do for the switch statement, nothing ever gets populate for the output conditions and manually adding one doesn't work.





Original Feedback:



I tried So I'm in the If Activity Editor now and I'm figuring out the condition. Instead of creating another variable to run the condition on, which one would I use to sort the condition by item?



Is it Display Name? or Item.Name?



It seems like this only allows me to set the conditions for a single action, not a 1<>1 mapping of condition to action.



Would the Switch Statement work instead? I tried the switch statement on Item Name and I don't get any output activities generated for my items. I even tried manually creating a condition and it looks like that didn't trigger either.



I'd need to send the user to a different next activity depending on the value:



if (itemName == "this"){


        do this;


}


else if(itemName == "other this"){


        do this2;


}






ifCondition.PNG