lookup then duplicate

Discussions about Cross-site Lookup
Locked
User avatar
dominique.beaudin
Posts: 49
Joined: Tue Mar 06, 2018

26 Jun 2019

So here is my situation. I have a list (drivers) that has a list of drivers. Sometimes when a new client is created, they utilize a driver who is already on the list. I want to be able to (in the "new"screen) look up a driver and COPY the information to a new record (so autofill the fields based on the "found" driver already in the list). I realized that might not be possible, but has anyone done something similar?

Thank in advance.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

26 Jun 2019

Dear Dominique,
There should be plenty of ways to do it, using either Cross-site Lookup functionality or JSOM requests. For example, you can retrieve extra fields by modifying Request items select query with Internal Names of the fields you want to retrieve:
RequestItems.png
RequestItems.png (16.29 KiB) Viewed 10800 times
Then, on the new form, you can use the following code to detect changes on the field and to retrieve items from it:

Code: Select all

fd.field('LookupToCopyFrom').change(function(){
  if(fd.field('LookupToCopyFrom').value().length > 0){
     //retrieve your extra fields and populate fields on the form
     fd.field('Title').value(fd.field('LookupToCopyFrom').control('data')['Title']);
     fd.field('Category').value(fd.field('LookupToCopyFrom').control('data')['Category']);
  }
});
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 11 guests