Populating a dropdown field value from parent

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
User avatar
dominique.beaudin
Posts: 49
Joined: Tue Mar 06, 2018

23 Dec 2019

in a "new" Form, I have created a function where when one dropdown item is selected (a driver), all that driver's information populates on the "new" form fields.

However, 2 of those fields are drops downs:'
- one is a list selection (single)
- the other is a lookup fields

Neither of these fields populate. I checked the java syntax area and it seems as though it should work -however the values never change.

What am I doing wrong?
Fields: AppState (select) / Driver_x0020_State (lookup)

Help is deeply appreciated. It feels like I'm missing something small (not very experienced with java)


Code:

fd.field('Driver_x0020_Lookup').change(function(){
if(fd.field('Driver_x0020_Lookup').value().length > 0){
//retrieve your extra fields and populate fields on the form
fd.field('First_x0020_Name').value(fd.field('Driver_x0020_Lookup').control('data')['First_x0020_Name']);
fd.field('Last_x0020_Name').value(fd.field('Driver_x0020_Lookup').control('data')['Last_x0020_Name']);
fd.field('License_x0020_Number').value(fd.field('Driver_x0020_Lookup').control('data')['License_x0020_Number']);
fd.field('AppState').value(fd.field('Driver_x0020_Lookup').control('data')['AppState']);
fd.field('GW_x0020_Rejected').value(fd.field('Driver_x0020_Lookup').control('data')['GW_x0020_Rejected']);
fd.field('Date_x0020_of_x0020_Birth').value(fd.field('Driver_x0020_Lookup').control('data')['Date_x0020_of_x0020_Birth']);
fd.field('CDL_x0020_Year').value(fd.field('Driver_x0020_Lookup').control('data')['CDL_x0020_Year']);
fd.field('Driver_x0020_State').value(fd.field('Driver_x0020_Lookup').control('data')['Driver_x0020_State']);
fd.field('Address1').value(fd.field('Driver_x0020_Lookup').control('data')['Address1']);
fd.field('Address2').value(fd.field('Driver_x0020_Lookup').control('data')['Address2']);
fd.field('City').value(fd.field('Driver_x0020_Lookup').control('data')['City']);
fd.field('Zip_x0020_Code').value(fd.field('Driver_x0020_Lookup').control('data')['Zip_x0020_Code']);
//fd.field('License_x0020_State_x003a_ID').value(fd.field('Driver_x0020_Lookup').control('data')['License_x0020_State_x003a_ID']);
// fd.field('Beneficiary_x0020_First_x0020_Na').value(fd.field('Driver_x0020_Lookup').control('data')['AppState']);

}

User avatar
mnikitina
Posts: 264
Joined: Wed Jun 05, 2019

25 Dec 2019

Hello Dominique,

Is Driver_x0020_Lookup a Cross-site lookup field?

Have you specified AppState and Driver_x0020_State in the Request items select query?

Please note to get the Title of the lookup field you need to expand the lookup field, so the syntax will be the following:

Code: Select all

function (term, page) {
  if (!term || term.length == 0) {
    return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,Title,Driver_x0020_State/Title,{LookupField}&$expand=Driver_x0020_State/Id&$orderby=Created desc&$top=10";
  }
  return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,Title,Driver_x0020_State/Title,{LookupField}&$expand=Driver_x0020_State/Id&$orderby={LookupField}&$filter=startswith({LookupField}, '" + encodeURIComponent(term) + "')&$top=10";
}
And JavaScript editor to get the value of the lookup field is:

Code: Select all

fd.field('Driver_x0020_Lookup').control('data')['Driver_x0020_State'].Title;

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests