1

I'm using Marc's SPServices jQuery library - the SPFilterDropDown script - to filter the items in a Lookup multi-select field on a New Item DVWP. It works fine if I stick some static text in there - but I'd like it to be dynamic.

I've tried a few versions.

var VARIABLE = $("#VARIABLE").html();
$(document).ready(function() {
$().SPServices.SPFilterDropdown({  
relationshipList: "{LISTID}",  
relationshipListColumn: "COLUMN",  
columnName: "FORMCOLUMN",  
listName: "{LISTID}",  
noneText: "(None)",  
CAMLQuery: "<Eq><FieldRef Name='VARIABLE' /><Value Type='Text'>'+ VARIABLE + '</Value></Eq>",  
completefunc: null,  
debug: true
});

The //var VARIABLE = $("#VARIABLE").html();// line is my attempt at making the dynamic piece work.

I've tried many variations on the CAML query:

- '+ VARIABLE + ' vs. {VARIABLE}
- Value Type='Text' vs. Value Type='Lookup'
- Eq vs. Contains

No luck. Looking for help.

4
  • perhaps you could add an example of the query string you're using too.
    – GavinB
    Commented Mar 12, 2012 at 1:05
  • Sorry - it parsed it out - I'll post today. Marc came to the rescue.
    – Cory M
    Commented Mar 12, 2012 at 11:25
  • Is there a reason you're using single quotes around the '+ VARIABLE +' instead of double quotes? I'll be honest, I don't know the jQuery library you're using, but it seems like you're expecting it to parse a strange combination of XML and jscript.
    – Neil White
    Commented Mar 12, 2012 at 13:27
  • Double quotes indeed were required - while searching the Web for solutions, I saw various forms of syntax so I was trying single quotes when I first posted.
    – Cory M
    Commented Mar 13, 2012 at 20:30

1 Answer 1

1

If nothing is happening, then it's likely your query string code block isn't working properly.

Look into his SPGetQueryString operation.

 $(document).ready(function() {
var queryStringVals = $().SPServices.SPGetQueryString();
 var yourVar = queryStringVals.theQSParam; 
    $().SPServices.SPFilterDropdown({   
    relationshipList: "{LISTID}",   
    relationshipListColumn: "COLUMN",   
    columnName: "FORMCOLUMN",   
    listName: "{LISTID}",   
    noneText: "(None)",   
    CAMLQuery: "<Eq><FieldRef Name='VARIABLE' /><Value Type='Text'>'+ yourVar + '</Value></Eq>",   
    completefunc: null,   
    debug: true 
    }); 
1
  • I came in to post more or less exactly what you posted here (plus double quotes around the variable in the CAML) - adding the SPGetQueryString made everything happy.
    – Cory M
    Commented Mar 13, 2012 at 20:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.