Hide lookup values

Hello,

I have a data table and one of the columns is a lookup dropdown. Is it possible to hide specific values from the lookup dropdown?

Thanks.

Hello @ParAvion,

You can configure a static or dynamic filter of the lookup column in List or Library control. Please find the example in our documentation here:
https://plumsail.com/docs/forms-sp/how-to/list-or-library-inline.html#filtering-lookup-fields-in-list-or-library-control

Thanks, what code would I use to filter out any lookup value that contacts "DO NOT USE" by default?

Hello @ParAvion,

You can apply a static filter using this code:

fd.spRendered(function() {
    fd.field('LookupField').ready().then(function() {
        fd.field('LookupField').filter = "Status eq 'DO NOT USE'";
        fd.field('LookupField').refresh();
    });
});

Replace LookupField and Status with the field internal names.

Hi @mnikitina,

I was never able to get the code you suggested to work. Here are my form details:

List or Library control = SPDataTable1
Lookup field = "Item"
Lookup value = anything that contains "Do not use"

When the form is in Edit mode, I would like any lookup value that contains "Do not use" to be dynamically filtered out of the lookup value results.

Is this possible?

Thank you!

Dear @ParAvion,
The List or Library control is different, but you can still apply filtering to it, here - Manipulate fields in inline editing mode of List or Library — SharePoint forms

@Nikita_Kurguzov thanks I've reviewed this page but have not been successful at applying it to my work case as mentioned above. thanks.

Dear @ParAvion,
What do you mean? You just need to make sure to change all the field Names to your ones, for example, if the Lookup value is derived from Status field:

fd.spRendered(function() {
    fd.control('SPDataTable1').$on('edit', function(editData) {
        //exclude Office values with LookupFieldName > Status 'Do not use'
        editData.field('Office').filter = "LookupFieldName/Status ne 'Do not use'";
    });
});

@Nikita_Kurguzov how do I use the code to exclude more than one item from the Lookup field? Your code can only exclude one item. Thank you!

Dear @ParAvion,
We're relying on SharePoint functionality for filtering, and unfortunately, it seems that there is a bug in the OData query filtering, which doesn't contain something - logical not of substringof() in 2013 REST API - SharePoint Stack Exchange

My code should work for different items, but the filtered field should be the same for all of them.

@Nikita_Kurguzov,

I've tried to filter out two values from the same field but still only one value will filter. No errors in console...is this what I should be doing? Thanks.

Dear @ParAvion,
One filter overwrites the other. If you want to have two conditions, do it like this:

fd.spRendered(function() {
    fd.control('SPDataTable1').$on('edit', function(editData) {
        //exclude Office values with LookupFieldName > Status 'Do not use'
        editData.field('Office').filter = "Title ne 'Do not use' and Title ne 'Stop'";
    });
});

There is a limit to how long a filter can be, so you won't be able to filter by dozens of options, but a few will definitely work.

1 Like