Skip to main content

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

Hi Andrew,

May I suggest to use a CSS Class as referencer instead of the Store Client ID in JavaScript variable.

I have noticed that for lookup, it works better.

Are you sure that your lookup values are available when your code is running?

Regards,

Christophe


Hi Christophe,

Sorry for late reply, it's been a busy few days.

All my look ups work great on their own. With 'client context query' I can pull all kinds of data based on the option selected in these look up fields. However rather than manually select "Area" from "Lookup2" I would like to select an option from "Lookup1" which populates a few fields and then puts its respective "Area" into "Lookup2".

Hopefully Lookup2 can be manually populated by whatever the Area is for Lookup1.

I can push Area into a single line text field, but cant find a way to push Area into a Lookup field.

Best Regards,

Andrew


The lookups I was trying to automatically populate were not connected to the list, they were just form look ups.

Looks ups that are connected to the list can be automatically populated (and changed if needs be). This is kind of like a multi-choice default value. The field says "Central" but you can change it to "whatever" you want after that.

Andy


Reply