[英]CRM2011 - Why are existing values being deleted when I add a new option set value using InsertOptionValueRequest
我试图使用InsertOptionValueRequest将新值添加到C#中的MS Dynamics CRM选项集中,并且在这样做时,一些现有的选项集值将被删除。
我使用的代码如下:
ovRequest = new InsertOptionValueRequest
{
AttributeLogicalName = strOptionsetName,
EntityLogicalName = strEntityName,
Label = new Label(strLabel, LanguageCode)
};
_service.Execute(ovRequest);
然后,我发布实体:
pxReq1 = new PublishXmlRequest { ParameterXml = String.Format("<importexportxml><entities><entity>{0}</entity></entities></importexportxml>", strEntityName) };
ospService.Execute(pxReq1);
我发现本地选项集和全局选项集都在发生这种情况,并且在删除的值中看不到任何模式。 我是在做错什么还是SDK中的错误?
PS,有人可以为此添加一个insertoptionvaluerequest标签,因为我认为该标签与本文最相关。
我找到了我问题的答案。 MS Dynamics不会删除现有值,它会覆盖现有选项设置值上的标签。 这绝对是一个错误,因为正在运行的命令是InsertOptionValueRequest,并且有一个单独的UpdateOptionValueReqequest用于更新值。
要解决此问题,请在插入记录时手动设置“值”,而不要依赖系统为您生成一个:
ovRequest = new InsertOptionValueRequest
{
AttributeLogicalName = strOptionsetName,
EntityLogicalName = strEntityName,
Label = new Label(strLabel, LanguageCode),
Value = MyNewValue
};
_service.Execute(ovRequest);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.