0

I am trying to grab a list of invoices where *customerid* is not null. I generate fetchxml query from advanced find and then put into a function of XRMServiceToolkit but it throws following exception.

Exception

Error Code:-2147220989 Message: An exception System.FormatException was thrown while trying to convert input value 'not-null' to attribute 'invoice.customerid'. Expected type of attribute value: System.Guid. Exception raised: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Code Snippet

Here is my code snippet.

function getinvoices()
{
var query = "<fetch mapping='logical' >"+
    "<entity name='invoice'>"+
        "<attribute name='name' >"+
        "<attribute name='customerid' >"+
        "<attribute name='statuscode' >"+
        "<attribute name='totalamount' >"+
        "<attribute name='invoiceid' >"+
    "<order attribute='name' descending='false' >"+
        "<filter type='and'>"+
            "<condition attribute='customerid' operator='not-null' >"+
        "</filter>"+
        "</entity>"+
"</fetch>";
    var retrievedInvoices = XrmServiceToolkit.Soap.RetrieveMultiple(query);

    alert(retrievedInvoices.length);

    }
AQ Dev
  • 43
  • 3
  • 14

2 Answers2

0

Your line should be var retrievedInvoices = XrmServiceToolkit.Soap.Fetch(query); for fetch queries.

Polshgiant
  • 3,595
  • 1
  • 22
  • 25
  • I tried it but it throwing another exception that is "Object doesn't support property or method 'slice'" – AQ Dev May 19 '16 at 13:11
0

This fetch query doesn't have closing tags in most nodes. Try this:

<fetch mapping='logical' >
  <entity name='invoice' >
    <attribute name='name' />
    <attribute name='customerid' />
    <attribute name='statuscode' />
    <attribute name='totalamount' />
    <attribute name='invoiceid' />
    <order attribute='name' descending='false' />
    <filter type='and' >
      <condition attribute='customerid' operator='not-null' />
    </filter>
  </entity>
</fetch>
pen2
  • 759
  • 5
  • 16