在Dynamics CRM 2011中将发票标记为已付款

Chr*_*yne 3 c# silverlight dynamics-crm dynamics-crm-2011

沿着这个问题的路线.

我正在尝试使用Silverlight将现有的Invoice标记为Dynamics CRM 2011中的付款.

根据文档,我需要做的就是设置状态代码= 100001和状态代码= 2.

当我这样做时,我得到一个"NotFound"异常.

Guid invoiceID = new Guid("Existing Invoice Guid");
IOrganizationService orgService = OrgServiceFactory.GetInstance();

orgService.BeginRetrieve("invoice", invoiceID, new ColumnSet(new string[] { "invoiceid", "statecode", "statuscode" }), (result) =>
{
    var fetchResp = orgService.EndRetrieve(result);

    var statecodeAttrib = fetchResp.Attributes.Single(a => a.Key == "statecode");
    OptionSetValue statecode = (OptionSetValue)statecodeAttrib.Value;
    statecode.Value = 2; 


    var statuscodeAttrib = fetchResp.Attributes.Single(a => a.Key == "statuscode");
    OptionSetValue statuscode = (OptionSetValue)statuscodeAttrib.Value;
    statuscode.Value = 100001;

    orgService.BeginUpdate(fetchResp, (updateResult) =>
    {
        /* Web Exception thrown here */
        orgService.EndUpdate(updateResult);
        Console.Write("");
    }, orgService);

}, orgService);
Run Code Online (Sandbox Code Playgroud)

如果我删除"statecode"位,并尝试将状态代码设置为2 - (部分发货)或4 - (结算),它将按预期工作.

只有当我尝试设置时它才会失败.如果我只是尝试设置statuscode = 100001,100002,100003(完成,部分,取消),它也会失败

还有另一种方法可以将发票标记为付款吗?

Mat*_*att 5

要更改记录的状态,您始终需要执行单独的SetState请求,而不是仅对状态和状态代码进行简单更新.在您的情况下,您可以执行SetStateDynamicEntitySetStateInvoice请求.

遗憾的是,CRM 2011中的OData服务无法提供这些消息.您需要做的是通过Silverlight使用SOAP Web服务.该SDK提供了一个演练,如果你想有一个良好的开端,在SilverCRMSoap库是一个很好迅速地实施这一演练.