cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

Filtered Lookup based on lookup field selection

Jump to solution

Hi guys

I have the following challenge. I have list from which the user selects a value from column A, based on that value I need to populate two other fields on the form with values from column B and C based on the selection made from column A.

I have tried using three look controls,

lkColA: does a souce list lookup and presents the required choices, I then use a calculated field strColA to parse the lookup value to have choice as str.

lkColB: does the same source list lookup and attempts to filter on the value in the in strColA and return a single filtered value from the item selected

lkColC: does the same source list lookup and attempts to filter on the value in the in strColA and return a single filtered value from the item selected

lkColA and strColA work fine, but the other two lookups do not filter on strColA.

The only way it works is if I hard code the choices for lkColA then filter lkColB and lkColC on the value selected on lkColA.

This is not a real solution as the choices in lkColA will change and i would have to keep updating the choices manually.

Clearly I am missing something

Frustrated

Labels: (1)
Tags (1)
0 Kudos
Reply
5 Replies
Highlighted
Nintex Newbie

Re: Filtered Lookup based on lookup field selection

Jump to solution

Hi Nandalal,

If I understand correctly, you just want to pull data from the list depending on what is selected in the look up form?

You can use JavaScript for that.

For example:

NWF$(document).ready(function(){

var lookup = NWF$("#" + YOURLOOKUP); 

NWF$("#" + YOURLOOKUP).change(function(){     

var web = clientContext.get_web();        

var oList = clientContext.get_web().get_lists().getByTitle("NAME OF YOUR LIST TO LOOKUP");     

var listItem = oList.getItemById(this.value);        

clientContext.load(listItem, "COLUMN A NAME", "COLUMN B NAME", "COLUMN C NAME");

//Then you should be able to assign JavaScript client IDs to a couple of text boxes on the form and retrieve the values based on what Is selected in Column A.//

clientContext.executeQueryAsync(function(){

var getColumnB = NWF$("#" + txtBoxForColumnB);

getColumnB.val(listItem.get_item('COLUMN B NAME'));

Lets say Column A is a "Product" and Column B is a "Price". The code above will run once the lookup field in the form is changed. The code will find the Item selected and look for the corresponding "Price" in column B. Then we need to display this "Price" value so we use a text box to assign the value to.

Hope I have understood you and hope this helps.

Andrew

View solution in original post

Reply
Highlighted
Not applicable

Re: Filtered Lookup based on lookup field selection

Jump to solution

Andrew

Where would I put these scripts?

Regards

Nandalal Ramphal

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Filtered Lookup based on lookup field selection

Jump to solution

Hi Nandalal,

Sorry for the late reply, I've had a crazy few days.

In Nintex forms you can add custom scripts by clicking on "Form Settings" Button (Picture of a form and a little orange cog).

then click the "+" Symbol beside "Custom JavaScript" and you can put all your code in the little box there.

Tip: When you're testing custom JavaScript it's advised to publish the form and test it, rather than use the "Preview" feature.

When testing your form if it does not appear and just shows a blank white screen then there is an error in your code and you will have to go back to it to fix it.

If you are having many problems when testing you can open F12 developer tools (should give hints to what the error is). To get this you hold "fn" on keyboard and press "F12". At least that's how it's done at my computer. If this is open when you click "New Item" it will show you any errors that occur when your form is opening.

Hope this helps!

Regards,

Andrew

0 Kudos
Reply
Highlighted
Not applicable

Re: Filtered Lookup based on lookup field selection

Jump to solution

Awesome thanks Andrew!

Regards

Nandalal Ramphal

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Filtered Lookup based on lookup field selection

Jump to solution

I have a similar request but I need to populate data into the form from a list on a different subsite. Can this be done?

In the old InfoPath days I would update fields based on a rule. I know I can't do that in Nintex.

0 Kudos
Reply