[RESOLVED] Create duplicate lookup column

Hi,

I have a requirement to create a duplicate lookup column which retrieves the same information that the submitter has provided.

This is useful for the edit form as make it easier for authorisers to distinguish between the submitters selections and the authorisers selections.

Is this possible?

Thanks!

Dear @DryChips,
Sure, first add another field, then this code:

fd.spRendered(function(){
  fd.field('Lookup1').ready(function(field) {
    field.$on('change', function(value) {
       fd.field('Lookup2').value = value;
    });
  });
});
1 Like

Hi Nikita,

This code doesn't seem to work.

I added two Lookup Staff group fields:

StaffGroup1
StaffGroup2

I want to pass Staff Group 2 value to Staff Group 1 field but no luck. I don't get any errors in console either.

fd.spRendered(function(){
  fd.field('Main_Staff_Group2').ready(function(field) {
    fd.field('Main_Staff_Group2').value.$on('change', function(value) {
       fd.field('Main_Staff_Group').value = fd.field('Main_Staff_Group2').value;
    });
  });
});

Dear @DryChips,
Yes, it wouldn't work, it's not value.$on, but instead:

fd.spRendered(function(){
  fd.field('Main_Staff_Group2').ready(function(field) {
    fd.field('Main_Staff_Group2').$on('change', function(value) {
       fd.field('Main_Staff_Group').value = fd.field('Main_Staff_Group2').value;
    });
  });
});

Or this:

fd.spRendered(function(){
  fd.field('Main_Staff_Group2').ready(function(field) {
    field.$on('change', function(value) {
       fd.field('Main_Staff_Group').value = fd.field('Main_Staff_Group2').value;
    });
  });
});

Hi Nikita,

None of the codes worked.

Dear @DryChips,
Just tested the code - created new lists, one with two identical lookups, created forms, copied and pasted the second code, here's the result:

How strange, it doesn't work on SharePoint 2019. I created a new TEST list and still nothing!

Dear @DryChips,
Just tested in SharePoint 2019 as well, here it is:

Can you show me the code on your form? How does it look like?

This is the code I am using to run the function:

fd.spRendered(function(){
  fd.field('Main_Staff_Group2').ready(function(field) {
    field.$on('change', function(value) {
       fd.field('Main_Staff_Group1').value = fd.field('Main_Staff_Group2').value;
    });
  });
});

Both lookup list are pointing to the EXACT same list. I just want them to have the same value on the 'New' form and then on the 'Edit' form the administrator can select the correct values.

Dear @DryChips,
No, I need a screenshot from the form:
image

Sure,

Dear @DryChips,
I see, strange, can you export and send me your form used in this video?

How strange, it doesn't work on SharePoint 2019. I created a new TEST list and still nothing!

Plumsail Test.xfds (1.6 KB)

Dear @DryChips,
I have just imported the form, and you have reverse of what you've posted here:

Hi, I literally just changed this now to see if that was the issue but no luck.

Dear @DryChips,
I have just imported your form, fixed the code, here's how it works:

Can you record the same video with form's code visible, and if it doesn't work - open the console in the browser to check for errors?

Sure, check this out:

I think I might know why this isn't working. My source list contains more than 1 column such as Role, Position Title, Band.

I think that the Main Staff Group2 field is unable to locate the EXACT item in the Main Staff Group1 field as the list contains duplicates....

Dear @DryChips,
It doesn't work this way:

I think that the Main Staff Group2 field is unable to locate the EXACT item in the Main Staff Group1 field as the list contains duplicates....

The value is set with ID, the duplicates don't matter. I don't see you saving the form after changing field names, so I cannot confirm that the code ran properly...

I don't see the type of the form you're changing, and I don't see the message that the form is saved:
image

The page also needs to be refreshed in the browser after saving in order for changes to apply.

Can you provide access to the site? I will test it myself, if you can send an invite to n.kurguzov@plumsail.com

Check out this video:

Dear @DryChips,
As I'm saying, I can't see anything wrong. If you can provide access - we'll test it for you. Otherwise it looks okay and should work, we've tested it in variety of ways.