This project has moved and is read-only. For the latest updates, please go here.

Query stopped working when including CreatedDate in WHERE clause

Oct 13, 2015 at 4:15 AM
Edited Oct 13, 2015 at 4:16 AM

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>";

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

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

                       var props = new Array()
                          var name = $(this).find("Name").text();
                          var val = $(this).find("Value").text();
Thanks in advance!
Oct 13, 2015 at 12:23 PM
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".

Oct 13, 2015 at 1: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!
Oct 13, 2015 at 8: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?