Solved

Passing variables and/or item ID to the Component Workflow?

  • 21 May 2019
  • 3 replies
  • 273 views

Badge +6

I was able to figure out passing variables from the component workflow to the main workflow once complete, but how do I even get the Item ID passed to the component workflow in order to run queries?  There is no "current item" option in the site workflows so running a query on the current item to get information seems impossible.

 

background/reason: I need to split up my HUGE workflow that has currently 235 activities and growing.  I have several sets of tasks I use repeatedly and all I need is a different set of values.  Or is there a way perhaps within a workflow to do like a script would in a Function that I can keep calling? Because that would be amazing!

icon

Best answer by burked 21 May 2019, 17:19

View original

3 replies

Userlevel 5
Badge +8

For the Component Workflow:

 

1) Setup an initiation variable for 'ID' as type 'Number'.

2) Setup your query list action to show items when column ID is equal to the ID Variable you created (output any values that are required for the rest of the action. These outputs will be stored as collections)

3) Publish your Component workflow (I included log to history list actions to show the ID before the query and results after the query)

 

For your parent workflow:

1) Insert Run Component Workflow action and select the component workflow you built.

2) For the ID input, select 'List Lookup' with a source of 'Current Item' and Field ID.

3) Publish your workflow and test!

 

Here are the results for my component workflow (using my log to history list action):

Badge +6

@burked Thanks so much!  That works beautifully!  Just one question, how did you get to the workflow history of that component workflow? I have some logic issues with it that I can't troubleshoot with the workflow history of the parent. 

Userlevel 5
Badge +8

You can view the component workflow history by going to Site Contents > Site Workflows

From there you will be able to see the running and completed component workflows.

In my component workflow, I included the two log to history list actions described in the previous post to get the output.  Hope this helps!

Reply