Tuesday 3 June 2014

Sorting the Lookup field values based on any columns on Lookup list using SPServices SPFilterDropdown

Hi Everyone,
 Today we will be seeing a common requirement which will used very frequently, and there is OOTB way to do this.

The requirement is "sorting the Lookup field values". Usually it gets sorted automatically "alphabetically".

Sometimes, we need to have them as in same order as they have stored in the list. For this we are going to sort the values of the lookup based on the ID on the lookup list.
Note : The lookup values can be sorted based on any columns. That depends on the requirement. For understanding i have used ID for that.

For this we are using SPServices, For using SPServices and to have a basic knowledge about SPservices, please refer here.

 $().SPServices.SPFilterDropdown({ //This is the function that does the sorting.
        relationshipList: "LookUp list", //This is the lookup list.
        relationshipListColumn: "Title", //This is the original column name from the lookup list as SharePoint knows it.
        relationshipListSortColumn: "ID", //This is the column in the lookup list to sort by.
        columnName: "LookUpcommitees", //This is the lookup field name .
        debug: true// have to be true on development times
    });


Have a good day:)

1 comment:

  1. This option is not working for me in sharepoint online

    ReplyDelete