0

Everything is fine I am able to fetching the data from SharePoint 2013 List using CAML query in my js file. But when i try to get the data via dropdown conditions my code is executing in the else statement .Can aone help me what went wrong in my below code

 alert('entered into SVV function');
var clientContext = new SP.ClientContext.get_current();
/*alert('Go Client Context');*/
var oList = clientContext.get_web().get_lists().getByTitle('Execution');
var drbregionvalue= document.getElementById("drbregion").value;
var drbfunctionsvalue= document.getElementById("drbfunctions").value;
var drbmonthvalue=document.getElementById("drbmonth").value;
var allvalue="ALL";

var camlQuery = new SP.CamlQuery();

if(drbfunctionsvalue!=allvalue && drbregionvalue!=allvalue)
{
alert('Your dropdown values for both are all');
camlQuery.set_viewXml("<View><Query><Where><And><Eq><FieldRef Name='Region'/><Value Type='Text'>" + drbregionvalue + "</Value></Eq><Eq><FieldRef Name='Title'/><Value Type='Text'>" + drbfunctionsvalue + "</Value></Eq></And></Where></Query></View>");
}
else
{
alert('Among 1 Dropdowns You selected all');

}
1
  • 1
    Try to put alert(drbfunctionsvalue) before if statement to see the actual value.
    – Martin P.
    Commented Mar 8, 2016 at 11:32

1 Answer 1

0

It's not all that clear what your conditions are supposed to be, but based on the alert messages you have, these make the most sense to me.

if(drbfunctionsvalue==allvalue && drbregionvalue==allvalue) //AND => both
{
    alert('Your dropdown values for both are all');
    camlQuery.set_viewXml("<...omitted...\>");
}
else if(drbfunctionsvalue==allvalue || drbregionvalue==allvalue) //OR => one
{
    alert('Among 1 Dropdowns You selected all');

}else{
    alert('Neither dropdown selected all');  //none selected all
}
1
  • Dear Paul / Martin, Thanks for your support.Found the issue as I was getting the dropdownlist default selected value.
    – MSA
    Commented Mar 9, 2016 at 5:56

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.