MSCRM 2011 CloseQuoteRequest离线

时间:2013-03-18 18:14:52

标签: plugins outlook dynamics-crm-2011 offline

我想从插件中关闭一个引用。一切都在线工作,但如果我的插件在Outlook中脱机运行,我将收到一个错误:

必须在离线模式下为富客户端上的平台调用填充主键

我这样关闭引用:

CloseQuoteRequest req = new CloseQuoteRequest();
req.QuoteClose = myQuote;
req.Value = new OptionSetValue(6);
service.Execute(req);

我在离线时跟踪了我的插件,我的属性就像我的报价ID一样。

有没有人有想法?

1 个答案:

答案 0 :(得分:0)

解决方案是使用后期绑定的quoteclose实体并提供activityid guid:

var item = service.retrieve("quote",quoteid, new columnset(true);
var quoteclose = new Entity("quoteclose");


quoteclose.Attributes.Add("quoteid", item.ToEntityReference());
quoteclose.Attributes.Add("subject", "Quote Closed");
quoteclose.Attributes.Add("description", "Quote Closed");
quoteclose.Attributes.Add("quotenumber", item.Attributes["quotenumber"]);
quoteclose.Attributes.Add("ownerid", item.Attributes["ownerid"]);
quoteclose.Attributes.Add("revision", 0);
quoteclose.Attributes.Add("activityid", Guid.NewGuid());
quoteclose.Attributes.Add("actualend", DateTime.Now);

// Close the quote
CloseQuoteRequest closeQuoteRequest = new CloseQuoteRequest()
{
     QuoteClose = quoteclose,
      Status = new OptionSetValue(5)
};
contextBag.Service.Execute(closeQuoteRequest);