AnsweredAssumed Answered

Get value from lookup control without selecting it first: Forms O365

Question asked by rstrole on Apr 1, 2016
Latest reply on Apr 5, 2016 by patrickabel

In the on-prem version of forms there is a lookup function in the calculated value control. I'm trying to replicate that functionality in O365 forms but am having a hard time (probably because my .js skills are lacking). Basically I have an employee people picker field on my form (that can be changed). I need to get a field from another list using employee as the filter (employee is unique in the other list so only 1 value is returned). I am open to any ideas how to do this but my current "solution" is as follows:

 

I created a hidden lookup control on the form that only returns the value I need (it recalculates when employee is changed so all is well there). My goal is to set a text box or calculated value based on the lookup control so I can use it in the form. The problem is that the value of the lookup control defaults to 'select a value' but I need the other value. I'm assuming it is just stored as an array and [0] is 'select a value' and [1] is the value I need but I don't know how to surface that data in .js. Help is appreciated... Here's a few things I have tried based on other posts and my knowledge of scripting in other languages:

 

#All were ran after document ready but I also threw in a delay just in case that wasn't long enough for the lookup to load

 

(NWF$('#'+lkpControl)[0]) #I would expect my value in index 0 or 1 but I get nothing.

 

ko.dataFor(NWF$('#'+lkpControl)[0]); #I've seen people on the forums use this to set data in a lookup but I couldn't get it to return anything. I tried index 0 and 1.

 

NWF$('#'+lkpControl).val('1') #I see this as the solution all over the forums but it sounds like it worked in older versions but not now. I tried it with index 0 and 1 and it didn't return anything.

Outcomes