One of the most demanding requirements in recent times is to have the cascading dropdown columns in SharePoint. There are many useful articles available over Internet to achieve this functionality, each using different methodologies and technologies.
This is one of the easiest ways to implement it. However, I need something more than what is explained in the above blog.
The above blog does explain how to get Cascading dropdowns work. It also highlights the 3 level cascading dropdowns, but what if the third dropdown values are duplicated that is if the first dropdown has Countries, the second has States and the third one holds the Cities. Now consider an instance where different Countries may have identical City Names then we get duplicate records in the Cities dropdown. So in very Simple words, all the dropdowns should contain unique values.
This is not a difficult task, we can get this done just by making little modifications to the existing SharePoint List and also to the Jquery provided by Marc Anderson. Lets walk through the steps to achieve this functionality:
1) Follow all the steps as per Marc Anderson’s blog (link provided above).
2) In the Cities List add one more Lookup Column named Country and look up the values from Countries List
3) When we add items to the Cities List along with the States also select Country values.
4) Now, we are done with the SharePoint List modifications, all we are left with is Jquery updates. Open the file “CascadingDropdowns.js” and look for the function “.SPServices.SPCascadeDropdowns” in this file
5) This function accepts many parameters, one of them is the CAML Query parameter. So we may feel that by adding the Query here we can filter based on first dropdown as well. But unfortunately the answer is NO as it doesn’t accept dynamic values in other words the value would be an hard coded value and hence we cannot pass the first dropdown value in this. The updated “CascadingDropdowns.js” file looks as below:
I am not a developer, but have been able to get the cascading drop-downs working. I need to implement your solution for removing duplicates, however cannot work out the location to insert your code from your comment ‘just before the Where Condition ends’.
I am using jquery.SPSERVICES-0.7.2.min.js. Would it be possible to advise exactly where to insert the code.
Appreciate your help in advance.
I haven’t looked at the latest version “jquery.SPSERVICES-0.7.2.min.js”. As per the SPServices JQuery used earlier, please find for “var R=”” and from here check for the ending tag of “Where” and add the follow the steps discussed in the article.
Not sure, if anything has changed for this logic in the latest SPServices, I’ll look into it and update the post accordingly, if required