我正在寻找将机会的状态代码设置为“不活动”或“关闭”所需的C#(控制台应用程序)语法。实际上我也想知道在哪里可以找到statecode的可用值,因为在字段属性中我看到数据类型是“Status”,但是我看不到可用的值。
提前谢谢
答案 0 :(得分:4)
机会的有效州代码:
statecode - statuscode
0 (Open) - 1 (In Progress), 2 (On Hold)
1 (Won) - 3 (Won)
2 (Lost) - 4 (Cancelled), 5 (Out-Sold)
因为您希望“关闭”商机,请使用LoseOpportunityRequest SDK消息“取消”商机。
答案 1 :(得分:2)
您需要使用LoseOpportunityRequest
来更改状态。还有一个WonOpportunityRequest
。作为更改为已关闭丢失状态的一部分,您需要创建opportunityclose
实体,该实体是LoseOpportunityRequest
处理的一部分。
LoseOpportunityRequest req = new LoseOpportunityRequest();
Entity opportunityClose = new Entity("opportunityclose");
opportunityClose.Attributes.Add("opportunityid", new EntityReference("opportunity", new Guid("D711C1BD-23DA-E011-94B4-1CC1DEF177C2")));
opportunityClose.Attributes.Add("subject", "Lost the Opportunity!");
req.OpportunityClose = opportunityClose;
// 4 = Cancelled and 5 = Out-Sold
req.Status = new OptionSetValue(4);
LoseOpportunityResponse resp = (LoseOpportunityResponse)_orgService.Execute(req);