AnsweredAssumed Answered

Push value into Lookup field

Question asked by andrew_valentine on Jun 22, 2015
Latest reply on Apr 5, 2016 by andrew_valentine

Hello everyone,

 

I have a lookup field called "SitesLookup" which provides users with a list of sites to select from. Once selected JavaScript runs on the form and pulls data such as "Management Area" and "Post Code" into the forms corresponding text fields.

 

I now need to look up another list, the "Management" list. I need to somehow take the value from "Management Area" and put that into the look up field called "ManagementLookup".

 

So far I have tried:

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

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

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

var web = clientContext.get_web();        

var oList = clientContext.get_web().get_lists().getByTitle("Sites");     

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

clientContext.load(listItem, "Title", "ManagementArea", "PostCode")

clientContext.executeQueryAsync(function(){

 

var sitManLook = NWF$("#" + ManagementLookup);

var sitManArea = NWF$("#" + ManagementArea);                

var sitPost = NWF$("#" + sitPostCode);

 

sitManLook.val(listItem.get_item('ManagementArea'));

sitManArea.val(listItem.get_item('ManagementArea'));

sitPost.val(listItem.get_item('PostCode'));

 

This did not put the Management area into the ManagementLookup field as I had hoped.

I then moved on and tried to populate the Management Area field first and try to push that to the lookup:

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

NWF$('#' + ManagementLookup).val(NWF$('#' + ManagementArea).val())};

 

I have 62 different management areas possibilities. Can anyone help me set the value of the ManagementLookup field to the Management Area pulled from the Sites Database?

 

(I know how to do a workflow to get data from ('ManagementList' where 'Management Area' = formFieldManagementArea') however the clients current Lotus Notes system pulls data "live" and having to save the document and wait for the workflows to run before re-opening the form does not have the same 'flowing' feel to it)

 

Andrew

Outcomes