Fetchxml抛出异常,用于检查guid的非空值

时间:2016-05-19 12:39:36

标签: javascript guid dynamics-crm-2016

我正在尝试获取*customerid*不为空的发票列表。我从高级查找生成fetchxml查询,然后放入XRMServiceToolkit函数,但它抛出异常。

异常

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).

代码段

这是我的代码段。

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

    }

2 个答案:

答案 0 :(得分:0)

对于抓取查询,您的行应为var retrievedInvoices = XrmServiceToolkit.Soap.Fetch(query);

答案 1 :(得分:0)

此获取查询在大多数节点中没有结束标记。试试这个:

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