1

Not able to get item collection by my CAML in date range, while able to get in simple CAML query.

Please any body let me know what is the correct format of passing date string.

function check_Submission() { 
    this.clientContext = new SP.ClientContext.get_current(); 
    var oList = clientContext.get_web().get_lists().getByTitle('Employee Sift Details');
    var startDateFx ="2015-11-17T20:21:11Z";
    var endDatFx ="2015-11-17T20:21:11Z"; 
    var StrQuery = '<View Scope=\'RecursiveAll\'>' +
                        '<Query>' +
                            '<Where>' +
                            '<Geq>' +
                                '<FieldRef Name='Sift_x0020_Date' />' +
                                '<Value Type='DateTime' IncludeTimeValue='FALSE'>'+endDatFx+'</Value>' +
                            '</Geq>' +
                            '</Where>' +
                        '</Query>' +
                '</View>';                              
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml(StrQuery);
    this.collListItem = oList.getItems(camlQuery);
    clientContext.load(collListItem);  
    this.clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded4), Function.createDelegate(this,this.onQueryFailed4));
}

function onQuerySucceeded4(sender, args) { 
    alert('Request sucwess');
}

function onQueryFailed4(sender, args) {
    alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
}    
1

The CAML query is exactly doing what you tell it to do..

Check your single quotes.. the string you build is messed up

var StrQuery = '<View Scope=\'RecursiveAll\'>'

Correct, you escaped the quotes

'<FieldRef Name='Sift_x0020_Date' />' +

Incorrect, either escape the single quotes or use a double-quote

  • hi Danny thanks for reply , I think single quote is correct because same type query working for other type column but not working in date type column the problem is only for date type. – Jahangir Alame Nov 5 '15 at 10:30
  • 1
    It is a free world, everyone is allowed to learn JavaScript in thier own time.. – Danny '365CSI' Engelman Nov 5 '15 at 10:43
  • Hi Danny Thanks , my problem been solved achualy problem was <FieldRef Name=\'Sift_x0020_Date\' /> here you catch correct palace – Jahangir Alame Nov 5 '15 at 11:15
  • Yes, you escaped the single quotes so they are included in the string.. Please mark the answer so it does not popup anymore in that list of 19000 unanswered questions. tnx – Danny '365CSI' Engelman Nov 5 '15 at 11:42

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.