Query stopped working when including CreatedDate in WHERE clause

Oct 13, 2015 at 3:15 AM
Edited Oct 13, 2015 at 3:16 AM
Hi,

I would like to thank you first for this wonderful library!
We are using it to filter out the site created before a certain date and it was working without any problems for years. Recently I noticed that when I am including 'CreatedDate' in WHERE clause, the query is failing with an error. Without including 'CreatedDate' in WHERE clause in the query, I debugged and found that the property 'CREATEDDATE' is coming fine in the xml response.

I have included the code below, any help will be highly appreciated


var queryText = "<QueryPacket xmlns='urn:Microsoft.Search.Query' Revision='1000'>"
      queryText += "<Query>"
      queryText += "<Range><StartAt>1</StartAt><Count>"+1000+"</Count></Range>"
      queryText += '<SupportedFormats><Format /></SupportedFormats>';
      queryText += "<Context>"
      queryText += "<QueryText language='en-US' type='MSSQLFT'>"
      queryText += 'SELECT Title, Path, Write, Author, CreatedDate, Size, Description FROM Scope() WHERE "ContentClass" = \'STS_Web\' AND "CreatedDate" >= \'2014-09-15t00:00:00\' ORDER BY "Write" DESC'
      //queryText += 'SELECT Title, Path, Write, Author, CreatedDate, Size, Description FROM Scope() WHERE "ContentClass" = \'STS_Web\' ORDER BY "Write" DESC'
      queryText += "</QueryText>"
      queryText += "</Context>"
      queryText += "</Query>"
      queryText += "</QueryPacket>";

      $().SPServices({
            operation: "Query",
            queryXml: queryText,
            completefunc: function(xData, Status) {
                $(xData.responseXML).find("QueryResult").each(function() {
                    maxresults = false;

                    var xml = $(this).text()
                    var results = {};

                    $(xml).find("Document").each(function(i){
                       var props = new Array()
                       $(this).find("Property").each(function(){
                          var name = $(this).find("Name").text();
                          var val = $(this).find("Value").text();
                          ...................
                          ..................
Thanks in advance!
Coordinator
Oct 13, 2015 at 11:23 AM
Are you getting any specific error in the response? The default "Crated Date" is called "Created", not "CreatedDate", so I have to assume that "CreatedDate" is a column you have created. Is it a managed property? The only other thing I see is that you're using a small "t". Try switching to a "T".

M.
Oct 13, 2015 at 12:07 PM
Thank you very much for quick response!

The error I am getting in response is - "<ResponsePacket xmlns="urn:Microsoft.Search.Response"><Response domain=""><Status>ERROR_SERVER</Status><DebugErrorMessage>System.NullReferenceException</DebugErrorMessage></Response></ResponsePacket>"

I tried 'Created' as well and that returned the same error. I also tried "CreatedDate" >= \'2015-09-15T00:00:00Z\' (with capital T and Z, without Z etc.) but always get the same error. I am fine if I can only compare the date and ignore the time part. All I want to do is I don't want to show the sites created before a certain date.

Yes, 'CreatedDate' is a managed property and this code was working fine for a long time. There were some environmental changes though, like something was done related to UAG (Microsoft Forefront Unified Access Gateway) and some patching was also done. I am still trying to find out but I am not sure when the environmental changes were done and when the code stopped working but do you think these changes might have caused the problem?

Thanks again!
Coordinator
Oct 13, 2015 at 7:56 PM
If it's the out of the box column you're trying to filter on, then it's "Created".

If there were changes to your environment, it's possible it's having an impact, but there's no way for me to know, really.

Is the CreatedDate managed property set up to be used in scopes?

M.