Set workflow variable in site workflow

  • 26 March 2019
  • 2 replies

I have been fighting with this for several hours now and I'm sure I'm doing everything right but I can't get a Set Workflow Variable action to work.


I have a site workflow that queries a list for all items that match particular properties. The query returns their IDs in XML in a collection. I then have a loop which extracts each ID value in turn and sets it as a workflow variable. So far, all of this is working.


I then have a Set Workflow Variable action that is supposed to lookup against the list using the ID. This keeps retreiving a null value. I try it inputting the ID variable (which I know is populating because I've logged it to workflow history) and it doesn't work. I try inputting a static value as a test and it still keeps returning a null value even though I know the field is populated in this list.


Is there an issue with using a list lookup to set a variable in a site workflow? I'm sure I'm doing the exact same thing that's work a hundred times before on list workflows and the only difference I can think of is that it's a site workflow.

2 replies

This sounds like an odd one - it should be quite possible to do what you are trying to do.


When you log the variable to history, do you see any additional characters such as quotes, or errant spaces? Is the variable you're assigning to an integer variable or a string?


Also the lookup that you are performing, is that happening inside of the same loop that is getting each ID value?


What type of field is the field that you are trying to return to the workflow? Also are there any authoring rules on the list (such as checkin/out). Are you running the workflow as yourself (or a user that can see the value in the list), and are you using an app step with elevated permissions anywhere?





"This should be possible" is basically what I was thinking for several hours as it failed to work.


There are no additional characters. The ID is being retrieved as a text value, but I tried converting it to an integer and using that instead, with exactly the same result.


Yes, the lookup is happening in the same loop as the ID value is retrieved.


I'm trying to return a text value, which comes back empty, and a date value, which comes back as 01/01/1001.


The item isn't checked out. The workflow is running as myself, and I'm a site collection admin. No elevated permissions.