I've created a Nintex form variable that is set from a dropdown list. How do I access that from the workflow? I tried setting a workflow variable to the form variable, but the form variable is not available.
Solved! Go to Solution.
The Complicated Way of Doing It:
(It would probably be a lot easier just to attach a Workflow Variable to a Calculated Control, or, Directly to the Form Variable. However, sometimes you can't do it so simply! See below for a simple way of doing it before trying to do it the Complicated way)
Sometimes you might need to grab the Workflow Variable from the Form Data XML. If so, you can follow these steps. This is what the overall workflow will look like:
Set up a few Workflow Variables as shown:
Set up some type of Task. I'm using a Request Data Task. Make sure that the 'Store Task ID in' has been set to your var_TaskItemID integer Workflow Variable.
Inside of the Task's Nintex Form, create a Drop Down Choice Control.
I named mine "someDropdown" because I'm creative.
Create a Form Variable. I named mine 'SomeFormVariable' because I'm creative.
That variable formula is:
If(someDropdown==="Option 1", "Value 1", If(someDropdown=== "Option 2", "Value 2", "Value 3"))
So. If you change the Selection to "Option 2" your Form Variable will be changed to "Value 2".
Note: I did not put anything in there for when you do not select something using the Drop Down. If you don't, it'll just be blank.
Save Your Form Now, and get back to your workflow.
Under your Task Action, place in a Query List action.
Setup the Query List Action as shown.
You'll want to point to whichever Task List that your Task was created in, and filter the returned Item by the ID that equals the Task Item ID you captured earlier. The field that you are looking for is the Form Data field which contains all of the XML used to regenerate / build the task's Nintex Form.
Set your var_TaskFormData to equal the Form Data field of the item as shown.
Now that you have the Form Data, put in a Query XML Action.
Configure it as shown.
the source should be XML, the XML should be the variable you stored the Task's Form Data in, the Process should be XPATH.
The actual XPATH will simply grab the value of the Form Variable that we named (in this case) 'SomeFormVariable', and we will push that value (result) to our Workflow Variable called 'var_ThatFormVariable'.
BTW: That XPath is just //SomeFormVariable
You now have a Form Variable inside of a Workflow Variable.
Email yourself using the Send Notification Action to prove to yourself that you're awesome!
The Simple Way Of Doing It:
Sometimes you don't need to do it the hard way.
With the simple way the workflow looks like:
And you only need the Workflow Variable
Set up your Task just like how it is in the 'Hard Way' example, and get to your Form Variables. Instead of just setting the Calculation, link the Form Variable to your Workflow Variable as shown.
This will result in the Form Variables data being pushed out to the Workflow Variable once you have submitted the Task Form.
Does this cover how to solve your problem?
I'm not creating tasks with this workflow. Is there really no simpler way of doing this? Maybe I'm missing the point of form variables, but it seems that if you can add a variable to the start form of a workflow and populate it with the value from a dropdown on the start form then you should be able to use it in the workflow without all these extraneous steps!
Oh. So you're just trying to grab the Form Variable from an actual ITEM.
Darn, I see. However, yeah, you'd still basically have to parse the Form Data from the Item. Instead of getting that Form Data from a Query List action, you could literally just plomp it down into an XML Query Action outright, and use a similar Xpath to retrieve the value using the name you had for the Form Variable.
Perhaps in the future they will consider increasing the usability and usefulness of Form Variables so that they can be exposed to a Workflow that is running on a List with that has at least (1) Content Type that has a valid Nintex Form associated to it.
Until then however, it's to the XML Dungeons with us!
Note: If you do not see the Reference, please see this thread:
Ah. Then you will have to Query the List Item, and grab the Form Data from the returned Item or Items, much like how I suggested doing in the original reply when I targeted the Task List Item, and grabbed it's Form Data.
I found the REALLY easy way to do this. Simply use the "Connected To" box in the Form Variables section. Any variables of the same type show up there automatically! Wow, can't believe I've been chasing my tail like this and it was right in front of my nose!