locked
Error: The ConditonOperator.Equal requires 1 value/s, not 0. Parameter Name: LastName RRS feed

  • Question

  • Hi, I'm trying to create a SOAP request for CRM Online, and I'm having issues with the Retrieve Multiple Action.

    I can retrieve all without using the conditionals, but it makes sense to be able to use the filters.

    Anyone know where the issue can be here?

    <s:Body>
        <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
            <query i:type="b:QueryExpression" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                <b:ColumnSet>
                    <b:AllColumns>false</b:AllColumns>
                    <b:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                        <c:string>firstname</c:string>
                        <c:string>lastname</c:string>
                    </b:Columns>
                </b:ColumnSet>
                <b:Criteria>
                    <b:Conditions>
                        <b:ConditionExpression>
                            <b:AttributeName>lastname</b:AttributeName>
                            <b:Operator>Equal</b:Operator>
                            <b:Values xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                                <c:anyType i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">Something</c:anyType>
                            </b:Values>
                        </b:ConditionExpression>
                    </b:Conditions>
                </b:Criteria>
                <b:EntityName>contact</b:EntityName>
                <b:Distinct>false</b:Distinct>
                <b:LinkEntities />
                <b:Orders />
                <b:TopCount>5</b:TopCount>
                <b:PageInfo>
                    <b:Count>0</b:Count>
                    <b:PageNumber>0</b:PageNumber>
                    <b:PagingCookie i:nil='true'/>
                    <b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>
                </b:PageInfo>
            </query>
        </RetrieveMultiple>
    </s:Body>

    Thanks!

    Amit



    • Edited by Amit Aswani RedAnt Thursday, October 1, 2015 3:55 PM Forgot to remove two test lines
    Thursday, October 1, 2015 3:54 PM

All replies

  • Hi Amit,

    You might trying to retrieve something like:

             QueryExpression q = new QueryExpression("contact");
             q.ColumnSet = new ColumnSet( new string [] {"firstname", "lastname"} ) ;
             ConditionExpression condition1 = new ConditionExpression();
             condition1.AttributeName = "lastname";
             condition1.Operator = ConditionOperator.Equal;
             condition1.Values.Add("Something");            
             FilterExpression filter1 = new FilterExpression();
             filter1.Conditions.Add(condition1);
             q.Criteria.AddFilter(filter1);
             _service.RetrieveMultiple(q);

    For this SOAP will be:

    
    
    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Body>
        <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
          <query i:type="a:QueryExpression" xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">
            <a:ColumnSet>
              <a:AllColumns>false</a:AllColumns>
              <a:Columns xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                <b:string>firstname</b:string>
                <b:string>lastname</b:string>
              </a:Columns>
            </a:ColumnSet>
            <a:Criteria>
              <a:Conditions />
              <a:FilterOperator>And</a:FilterOperator>
              <a:Filters>
                <a:FilterExpression>
                  <a:Conditions>
                    <a:ConditionExpression>
                      <a:AttributeName>lastname</a:AttributeName>
                      <a:Operator>Equal</a:Operator>
                      <a:Values xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                        <b:anyType i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">Something</b:anyType>
                      </a:Values>
                      <a:EntityName i:nil="true" />
                    </a:ConditionExpression>
                  </a:Conditions>
                  <a:FilterOperator>And</a:FilterOperator>
                  <a:Filters />
                </a:FilterExpression>
              </a:Filters>
            </a:Criteria>
            <a:Distinct>false</a:Distinct>
            <a:EntityName>contact</a:EntityName>
            <a:LinkEntities />
            <a:Orders />
            <a:PageInfo>
              <a:Count>0</a:Count>
              <a:PageNumber>0</a:PageNumber>
              <a:PagingCookie i:nil="true" />
              <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>
            </a:PageInfo>
            <a:NoLock>false</a:NoLock>
          </query>
        </RetrieveMultiple>
      </s:Body>
    </s:Envelope>


    Thursday, October 1, 2015 4:36 PM
  • Hi ChangeFrenzoId,

    Thanks for your reply. I have tried variations from your reply, but unfortunately haven't managed to get the correct result:

    From the Request:

    <s:Body>
        <RetrieveMultiple
            xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
            <query
                i:type="a:QueryExpression"
                xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts"
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                <a:ColumnSet>
                    <a:AllColumns>false</a:AllColumns>
                    <a:Columns
                        xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                        <b:string>firstname</b:string>
                        <b:string>lastname</b:string>
                    </a:Columns>
                </a:ColumnSet>
                <a:Criteria>
                    <a:Conditions />
                    <a:FilterOperator>And</a:FilterOperator>
                    <a:Filters>
                        <a:FilterExpression>
                            <a:Conditions>
                                <a:ConditionExpression>
                                    <a:AttributeName>lastname</a:AttributeName>
                                    <a:Operator>Equal</a:Operator>
                                    <a:Values
                                        xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                                        <b:anyType i:type="c:string"
                                            xmlns:c="http://www.w3.org/2001/XMLSchema">Something
                                        </b:anyType>
                                    </a:Values>
                                    <a:EntityName i:nil="true" />
                                </a:ConditionExpression>
                            </a:Conditions>
                            <a:FilterOperator>And</a:FilterOperator>
                            <a:Filters />
                        </a:FilterExpression>
                    </a:Filters>
                </a:Criteria>
                <a:EntityName>contact</a:EntityName>
                <a:Distinct>false</a:Distinct>
                <a:LinkEntities />
                <a:Orders />
                <a:TopCount>5</a:TopCount>
                <a:PageInfo>
                    <a:Count>0</a:Count>
                    <a:PageNumber>0</a:PageNumber>
                    <a:PagingCookie i:nil='true'/>
                    <a:ReturnTotalRecordCount>false</a:ReturnTotalRecordCount>
                </a:PageInfo>
                <a:NoLock>false</a:NoLock>
            </query>
        </RetrieveMultiple>
    </s:Body>


    I get the response:

    [error] [msdynamics-crm-retrieve:Retrieve Multiple Entity] Error: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:query. The InnerException message was 'There was an error deserializing the object of type Microsoft.Xrm.Sdk.Query.QueryBase. The prefix 'b' is not defined. Line 18, position 148.'.  Please see InnerException for more details.

    So if I go back to the Prefix "b" just for the query expression (leave the rest of the prefix as "a", I get a reply, but the filters aren't applied, so I get a response with all of the entries (whatever TopCount has).

    On the other hand, if I change the prefix to "b", I get the following:

    <s:Body>
        <RetrieveMultiple
            xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">
            <query
                i:type="b:QueryExpression"
                xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts"
                xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                <b:ColumnSet>
                    <b:AllColumns>false</b:AllColumns>
                    <b:Columns
                        xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                        <c:string>firstname</c:string>
                        <c:string>lastname</c:string>
                    </b:Columns>
                </b:ColumnSet>
                <b:Criteria>
                    <b:Conditions />
                    <b:FilterOperator>And</b:FilterOperator>
                    <b:Filters>
                        <b:FilterExpression>
                            <b:Conditions>
                                <b:ConditionExpression>
                                    <b:AttributeName>lastname</b:AttributeName>
                                    <b:Operator>Equal</b:Operator>
                                    <b:Values
                                        xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
                                        <b:anyType i:type="c:string"
                                            xmlns:c="http://www.w3.org/2001/XMLSchema">Something
                                        </b:anyType>
                                    </b:Values>
                                    <b:EntityName i:nil="true" />
                                </b:ConditionExpression>
                            </b:Conditions>
                            <b:FilterOperator>And</b:FilterOperator>
                            <b:Filters />
                        </b:FilterExpression>
                    </b:Filters>
                </b:Criteria>
                <b:EntityName>contact</b:EntityName>
                <b:Distinct>false</b:Distinct>
                <b:LinkEntities />
                <b:Orders />
                <b:TopCount>5</b:TopCount>
                <b:PageInfo>
                    <b:Count>0</b:Count>
                    <b:PageNumber>0</b:PageNumber>
                    <b:PagingCookie i:nil='true'/>
                    <b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>
                </b:PageInfo>
                <b:NoLock>false</b:NoLock>
            </query>
        </RetrieveMultiple>
    </s:Body>
    

    The response is:

    The ConditonOperator.Equal requires 1 value/s, not 0. Parameter Name: LastName

    <s:Envelope
        xmlns:s="http://www.w3.org/2003/05/soap-envelope"
        xmlns:a="http://www.w3.org/2005/08/addressing"
        xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
        <s:Header>
            <a:Action s:mustUnderstand="1">http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/RetrieveMultipleOrganizationServiceFaultFault</a:Action>
            <a:RelatesTo>urn:uuid:332f12bf-79dc-434a-99ba-92f2764ca3df</a:RelatesTo>
            <ActivityId CorrelationId="e044d9a2-efbd-4b68-8d37-fb6017be3041"
                xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000
            </ActivityId>
            <o:Security s:mustUnderstand="1"
                xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
                <u:Timestamp u:Id="_0">
                    <u:Created>2015-10-02T09:17:02.178Z</u:Created>
                    <u:Expires>2015-10-02T09:22:02.178Z</u:Expires>
                </u:Timestamp>
            </o:Security>
        </s:Header>
        <s:Body>
            <s:Fault>
                <s:Code>
                    <s:Value>s:Sender</s:Value>
                </s:Code>
                <s:Reason>
                    <s:Text xml:lang="en-US">The ConditonOperator.Equal requires 1 value/s, not 0. Parameter Name: LastName</s:Text>
                </s:Reason>
                <s:Detail>
                    <OrganizationServiceFault
                        xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"
                        xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                        <ErrorCode>-2147220989</ErrorCode>
                        <ErrorDetails
                            xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                            <Message>The ConditonOperator.Equal requires 1 value/s, not 0. Parameter Name: LastName</Message>
                            <Timestamp>2015-10-02T09:17:02.1788825Z</Timestamp>
                            <InnerFault>
                                <ErrorCode>-2147220989</ErrorCode>
                                <ErrorDetails
                                    xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                                    <Message>The ConditonOperator.Equal requires 1 value/s, not 0. Parameter Name: LastName</Message>
                                    <Timestamp>2015-10-02T09:17:02.1788825Z</Timestamp>
                                    <InnerFault>
                                        <ErrorCode>-2147220970</ErrorCode>
                                        <ErrorDetails
                                            xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic"/>
                                            <Message>System.ArgumentException: The ConditonOperator.Equal requires 1 value/s, not 0. Parameter Name: LastName</Message>
                                            <Timestamp>2015-10-02T09:17:02.1788825Z</Timestamp>
                                            <InnerFault i:nil="true"/>
                                            <TraceText i:nil="true"/>
                                        </InnerFault>
                                        <TraceText i:nil="true"/>
                                    </InnerFault>
                                    <TraceText i:nil="true"/>
                                </OrganizationServiceFault>
                            </s:Detail>
                        </s:Fault>
                    </s:Body>
                </s:Envelope>

    Any ideas?

    Thanks again!

    Amit

    Friday, October 2, 2015 9:26 AM