1

One of the Projects I am working on, I have a site lookup column being used in many libraries across various subsites. The list column to which the lookup column is referenced to has some duplicate values, the reason is because they have other metadata fields that contain different value. So this is why the lookup column shows some duplicates.

Is there anyway possible to only show unique values in the lookup drop-down by leveraging JSOM since I am working with Office 365/SharePoint online.

Thanks in advance.

2

There's no inherent way to filter out duplicates. You could write a client side script to scan the options and filter out the duplicates, but which of the duplicates should it take? Is it just the "Title" that's important? If it creates a link to the lookup item, is that reference important?

Here's what I would do.

  1. Create a calculated column that combines Title + Some Other Field to create a unique, non-ambiguous value.
  2. Change the lookup to reference the new calculated column for its display, instead of the default Title or whatever it's set to
  3. When you pick from the dropdown now, you'll see your calculated value that makes it clear which item you're selecting.

UPDATE!

Ok, if you really only want the unique values from a field in another list, you might consider creating a separate list that stores these values and have both lists reference this same list. In terms of relational design, that would be optimal.

However, in SharePoint, we know things aren't always optimal. You have to cut corners. So a similar approach would be to create the 3rd list with the unique values, and automatically add items to this list through a workflow whenever the original "lookup" list has an item added/updated. Then your 2nd list would reference this instead.

Again, you could also just create a script to scan the select options and remove duplicates by name... jquery could do this in a few lines of code, but this feels bad to me. Just my 2c.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.