locked
Filter criteria issue in soap query RRS feed

  • Question

  • I want to fetch appointment details through soap query. If i am not using filteration query is returning data, but if i am using filteration data is not showing. I am not understanding what i am doing wrong. Below is my code, appriciate if any body can help. I am using CRM2011.

      var xml = "" +
      "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
      "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
      GenerateAuthenticationHeader() +
      "  <soap:Body>" +
      "    <RetrieveMultiple xmlns=\'http://schemas.microsoft.com/crm/2007/WebServices\'>" +
      "      <query xmlns:q1=\'http://schemas.microsoft.com/crm/2006/Query\' xsi:type=\'q1:QueryExpression\'>" +
      "        <q1:EntityName>filteredAppointment</q1:EntityName>" +
      "        <q1:ColumnSet xsi:type=\'q1:ColumnSet\'>" +
      "          <q1:Attributes>" +
      "            <q1:Attribute>activityid</q1:Attribute>" +
      "            <q1:Attribute>actualstart</q1:Attribute>" +
      "          </q1:Attributes>" +
      "        </q1:ColumnSet>" +
      "        <q1:Distinct>false</q1:Distinct>" +
     "        <q1:Criteria>" +
      "          <q1:FilterOperator>And</q1:FilterOperator>" +
      "          <q1:Conditions>" +
      "            <q1:Condition>" +
      "              <q1:AttributeName> actualstart</q1:AttributeName>" +
      "              <q1:Operator>ge</q1:Operator>" +
      "              <q1:Values>" +
      "                <q1:Value xsi:type=\"xsd:DateTime\">'2013/07/18T17:00:00 +5:30' </q1:Value>" +
      "              </q1:Values>" +
      "            </q1:Condition>" +
      "          </q1:Conditions>" +
      "        </q1:Criteria>" +
      "      </query>" +
      "    </RetrieveMultiple>" +
      "  </soap:Body>" +
      "</soap:Envelope>";
      
            var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
            xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
            xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
            xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
            xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
            xmlHttpRequest.send(xml);
            // retrieve response and find attribute value    
            var result = xmlHttpRequest.responseXML.selectNodes("//q1:actualstart");
            if (result == null)
                return "";
            else
                return result.text;

    Friday, July 19, 2013 2:39 PM

All replies

  • By "Filterisation", do you mean the FilterOperator? If so, try removing the leading space where it says "actualstart" in your filter. That might be causing the issue.
    • Proposed as answer by Roshan Mehta Monday, July 22, 2013 1:02 AM
    Monday, July 22, 2013 1:02 AM