I am working on a sharepoint online classic team site. where i added a custom list named "Pricing", which contain these main 2 fields:-

1) a column named "Type" of type drop-down list and have 2 options (General or Detailed).

2) a column named "Parent" of type lookup, which reference the same list (self-lookup field).

now the "Parent" lookup field will show all the items from the current list (Pricing), but i want the lookup field to only show the items which have "Type" = "General". so is it possible to apply filtering to the lookup columns? Thanks

  • 1
    You can use calculated column to filter lookup list. Check this sharepoint.stackexchange.com/questions/18247/… – P S Mar 18 '19 at 14:02
  • @PS the user who answered the question deserve all the votes,,, simple and smart solution!! have you tried this on reality before? – SharePoint TestDev Mar 18 '19 at 15:32
  • 1
    Yes, the calculated column solution work and I used that before. – P S Mar 19 '19 at 6:22
  • @PS if you add your comment as an answer so i can accept it.. thanks – SharePoint TestDev Mar 22 '19 at 1:38

As mentioned in comments, you can use calculated column,to get values where "Type" is "General". Then use this calculated column in lookup column.

For more information: How to make a filtered lookup field

| improve this answer | |

We can add the code below into a script editor web part in new/edit form page to remove all the items which have "MyType"="Detailed".

Note: By default the "Type" field is exists, I create a field name "MyType" to instead it.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
var listName="Pricing";
        url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items?$filter=MyType eq 'Detailed'",
        type: "GET",               
        headers: {
            "Accept": "application/json;odata=verbose",
        success: function (data) {
                $("select[title='Parent'] option").each(function(){
        error: function (error) {
| improve this answer | |
  • thanks for the code and valuable help.. but in sharepoint online (where we can not be sure if the markup will change), is it advisable to write such a script? i mean this selection $("select[title='Parent'] option") might not work in the future... or this is not the case? – SharePoint TestDev Mar 19 '19 at 1:54
  • 1
    If the field name changed, we need modify the code. – LZ_MSFT Mar 19 '19 at 3:11

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.