0

I have 3 lookup columns.

  1. Site - lookup column to specify type of environment (prod or non-prod)
  2. Operating System - lookup column to specify operating system to be used (linux or windows)
  3. Templates - lookup column that displays list of templates for linux and windows.

Basically, i want to filter the templates base on the type of environment and operating system. i'm using SPServices.SPCascadeDropdowns as solution. the problem is, cascade only works when form is loaded for the first time so in order to select different template whether for linux or windows, form needs to be refreshed. i am new to sharepoint and spservices. appreciate your help on this. below is the code

$(document).ready(function(){
$("select[title='Operating System']").change(function() {
    if ($("select[title='Operating System']").val() != 2)
    {
    queryCAML = "<Eq><FieldRef Name='Operating_x0020_System'/><Value Type='Lookup'>Windows</Value></Eq>",
    osType()
    }
    else
    {
    queryCAML =  "<Eq><FieldRef Name='Operating_x0020_System'/><Value Type='Lookup'>Linux</Value></Eq>",
    osType()
    }
}); 
});

function osType() {
    var osValue = $("select[title='Operating System'] option:selected").text();
            alert (osValue);
            alert (queryCAML);
            $(document).ready(function(){
            $().SPServices.SPCascadeDropdowns({
                relationshipList: "TEST VM Templates",
                relationshipListParentColumn: "Site",
                relationshipListChildColumn: "Template",
                CAMLQuery: queryCAML,
                parentColumn: "Site",
                childColumn: "Template",
                debug: true
            })
        }); 
} 
0

I suggest you provide the all list structure for further research.

Are those lookup columns from only one list "TEST VM Templates"?

We can also use REST API with jQuery Ajax to instead of SPCascadeDropdowns to achieve dynamic filter.

| improve this answer | |

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.