Skip to main content

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.

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: 

211099_pastedImage_19.png

 

Set up a few Workflow Variables as shown: 

211092_pastedImage_2.png

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.

211093_pastedImage_9.png 

Inside of the Task's Nintex Form, create a Drop Down Choice Control.

211094_pastedImage_10.png

I named mine "someDropdown" because I'm creative. 

211095_pastedImage_11.png

Create a Form Variable. I named mine 'SomeFormVariable' because I'm creative. 

211096_pastedImage_12.png

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. 

211097_pastedImage_13.png

Now that you have the Form Data, put in a Query XML Action. 

Configure it as shown. 

211098_pastedImage_15.png

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! 

211100_pastedImage_21.png

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: 

211101_pastedImage_27.png

And you only need the Workflow Variable

211103_pastedImage_29.png

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. 

211104_pastedImage_30.png

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. 

211105_pastedImage_12.png

Form Variables are simply meant to be a less difficult way of using data on the form that doesn't necessarily need to be exposed as something tied to an actual Control, and doesn't require getting dirty with Javascript. If you wanna access that data from outside of the form you can, but you'll certainly have to dig into the XML unless you feel that the data is important enough to store inside of an actual SharePoint Column

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! 


How do I get {ItemProperty:FormData} to show in the XML field? I couldn't find it from Insert Function, and when I typed it in the wf didn't seem to recognize it.


It should be in the Item Properties tab as shown

211116_pastedImage_1.png 


Note: If you do not see the Reference, please see this thread: 

https://community.nintex.com/message/72770-re-formdata-is-missing-under-itemproperties?commentID=72770#comment-72770 


nmarples I don't see the Item Properties section. This is a site workflow and I have published the form.

211118_pastedImage_1.png


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!

211313_pastedImage_1.png


If you look at my answer, that method was discussed in the section called "The Simple Way of Doing It" 

grin.png wink.png 

Edit: It should be noted that the reason I did both the Complicated and the Simple way of accomplishing this is mainly due to the fact that certain types of data, whether from the Form Control Type, or the Workflow Variables won't play nice with the simple way of doing things. 

This way you now know what to do if you ever run into those strange situations where you're messing with controls that do not want to connect up to a Workflow Variable, or have a workflow variable that is not exposed as a connectable variable inside of the Form Controls. 

Good to know you got it working! 


Yes, you are right. Sorry about that! I re-marked your answer as correct.


Reply