New Responsive Form - Can't put form variable into formula

  • 4 October 2021
  • 5 replies
  • 109 views

This has been frustrating for me because it seems it should be simple. I have a form with a list lookup control that links to a parts list in the same site. The user can select a part number using that control. What I would like is to have a read-only text control that auto-fills the part description, based on the part number selected. Seems to me this formula would be the logical way to accomplish this:

Lookup("Parts", "Part Num", Form.Part, "Description")

...but Nintex does not allow me to insert a value from another control nor from a form variable into the Form.Part part of the formula.  What am I missing?

 

 

 


5 replies

Userlevel 1
Badge +6

You are pretty close in your formula. You just need to change one thing from what I can see. This is one I have that looks up the address for a customer.


 


lookup("Customers","ID",parseLookup([Form].[Customer Lookup],false),"Address")



  • Customers is the list where the data is located

  • ID is the list item ID for the item selected in the drop-down

  • Now this is what you are missing:

    • You need to add a parseLookup function to your form field and set the return value to false, which will return the ID of the item in the list.



  • Address is the field I want to return and populate on the form


 


However, for your scenario, since you want to match on "Part Num" for the lookup, you need to change the parseLookup to true, which will return the value in the field instead of the ID of the selected item in the drop-down. If your Part Num field is an integer, you will need to modify the parseLook to convert it to a number. For example, convertToNumber(parseLookup([Form].[Part Num],false)).

David - Thanks for your quick reply. parseLookup seems promising, but I'm running into the same roadblock. I cannot insert the list lookup control into the formula - it's not in the list of variables from which to choose (it only has SharePoint columns, Context, or Form mode), and if I try to type [Form].[SelectPart], the parser tells me "the function requires a 'string' type of parameter." and "Variable '[Form].SelectPart]' cannot be found." For simplicity, I'm just trying this:


parseLookup([Form].[SelectPart], false)


...and I see those errors. It's almost as if there's something wrong with my list lookup control. (?)


Trying another approach, I created a form variable called varPart with the value [Form].[SelectPart], and that appears to work. Trouble is, I can't figure out how to make use of the form variable.


 

Userlevel 1
Badge +6

It sounds like what you have is correct. You might try wrapping your entire formula in a convertToString function. It seems like the data you are looking up might be a different data type than the field you are trying to populate. By wrapping your formula in the convertToString function, it will ensure it returns a string.


 



  • convertToString(lookup("Customers","ID",parseLookup([Form].[Customer Lookup],false),"Address"))


 


Good luck!

Is there something fundamentally wrong with my form?  The documentation for parseLookup suggests that I can insert my list lookup control, but it won't accept any form of the blue parameter.



On mine, I think it should be [Form].[SelectPart], but there seems to be no [Form] object available to me.


One other point: This is a list form, not a workflow form, if that matters.

I'm getting closer, thanks to Euan Gamble's video (https://www.youtube.com/watch?v=aa1JM3vEhxY). I can do the lookup successfully in a form variable, then insert that variable into a label control. My formula is


lookup("Parts", "ID", parseLookup([Form].[SelectPart], false), "Description")


My remaining problem is that I would like that result to be in a bound control, so that it is saved to my list. Evidently, I cannot insert either that variable or that formula into a text control bound to the list's Description column (or even unbound). If you can have another suggestion, please share.


And, thanks for your help!

Reply