Advice for SP2013 on prem workflow templates that include variables?

  • 23 March 2017
  • 3 replies
  • 2 views

Badge +5

Here's my situation: I have ten nearly-identical workflows that might or might not start each time an item is created, depending on what exactly is in the item.  Workflow1 will look at list columns A1, B1, C1; Workflow2 will look at list columns A2, B2, C2, etc.

I'm trying to figure out the best way to build this once and be able to copy it with as little tweaking required as possible on each individual workflow.  Any advice at all is welcome.  Would you use the Export/Import options on the ribbon, or save as the workflow as a snippet, or something else entirely?  My first impulse is to save as a snippet, but if I'm not mistaken that means that I would lose my workflow variables and have to recreate them in each of the ten workflows.


3 replies

Badge +5

Update: just realized that saving as a snippet and dropping the snippet into a new workflow does bring in variables.  Any other thoughts are still welcome.

Userlevel 4
Badge +12

Hi Andrew,

having 10 nearly identical workflows seems not very good to administer. In general, saving the stuff as a snippet will help you duplicate the actions but once you recreate the actions in the next workflow they will not be related to the original snippet. Means: when you overwrite the snippet it will have no effects to the other reused snippets in your workflow.

Basically you just helped yourself copying dozens of actions again and again.

Would an User Defined Action be something that can help you? This is truly a small workflow that's designed once, gets some input variables and returns some output variables. You can reuse the UDA as one single action in your 10 workflows and give it the appropriate parameters. The actions within the UDA are stored only once and when you change the UDA you can also update all workflows that use it at once.

Would this be an option?

Kind regards,

Enrico

Badge +5

Hi Enrico,

Thank you for the reply.  I have not used UDAs before, but I'm starting to learn about them.  I think they might work for this situation.  The challenge is that I would need to query for the value of a column whose name is partially defined by a variable in the UDA.

Here's what I would like to do with the UDA.  I thought I could give it as input an integer, like a counter, and then use that counter to target a specific column in my list.  So if the input was 1, I could, within the UDA, fill a variable with the value of column A1 from the column and then output that from the UDA, or if the input was 2, I would ouput the value of column A2, etc.

I tried doing this with the "Set variable" action inside a UDA, but as you can see below there is no way to target a column like Owner[variable].

I am now trying something with the "Query list" action and a CAML query, where it looks like I can use the input parameter to help define the target column.  However, my intial tests are getting an error from the UDA saying "Object reference not set to an instance of an object."...

Reply