c# - Dynamics CRM 2016 on-premise 禁用用户不起作用
问题描述
我们升级到 CRM 365 on-premise (8.2.2),我们正在使用自定义代码来停用用户,(将数据移动到另一个用户和其他东西)。最后,我们使用这个示例代码:https ://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/sample-disable-user 但升级后我们不再适用。
现在我们得到 '-1 is not a valid state code on mailbox with Id' 并查看服务器上的错误,如下所示:
[2018-09-17 08:07:45.297] 进程:w3wp |组织:|线程:9 |类别:Platform.Sdk |用户:|级别:错误 |ReqId:129694cd-1d73-4723-8d3e-ca9487294697 |ActivityId: ad01991a-c02a-4f1e-9db1-3a936a432752 | VersionedPluginProxyStepBase.Execute ilOffset = 0x64
SdkMessageProcessingStepId 中的 Web 服务插件失败:{57CDBB1B-EA3E-DB11-86A7-000A3A5473E8};实体名称:系统用户;阶段:30;消息名称:SetStateDynamicEntity;程序集名称:Microsoft.Crm.Extensibility.InternalOperationPlugin,Microsoft.Crm.ObjectModel,版本=8.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35;类名:Microsoft.Crm.Extensibility.InternalOperationPlugin;异常:未处理的异常:System.Reflection.TargetInvocationException:调用的目标已引发异常。在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) 在 System.Reflection.RuntimeMethodInfo。调用(对象 obj,BindingFlags invokeAttr,Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider serviceProvider) 在 Microsoft.Crm .Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext context) at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context) 内部异常:Microsoft.Crm.CrmArgumentException:-1 不是 Id 邮箱上的有效状态代码。在 Microsoft.Crm.BusinessEntities.BusinessProcessObject.SetState(BusinessEntityMoniker moniker, Int32 newState,
1.SetState(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context) at Microsoft.Crm.ObjectModel.SystemUserServiceInternal
1.SetMailboxState(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context) 在 Microsoft.Crm.ObjectModel.SystemUserServiceInternal`1.SetState(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context) 在 Microsoft.Crm.ObjectModel.SystemUserService。 Microsoft.Crm.Sdk.IStateful.SetStateStatus(BusinessEntityMoniker, Int32, Int32, ExecutionContext) 内部异常:System.ArgumentException:-1 不是 Id 邮箱上的有效状态代码。参数名称:stateCode
所以我尝试先停用用户邮箱,但没有帮助。还是同样的问题。有人有同样的问题并以某种方式解决了吗?
解决方案
尝试使用 IOrganizationService.Update() 方法来更新 statecode/statuscode 字段。
_service.Update(new SystemUser{ Id = <systemuserid>, StateCode= new OptionSetValue(1), StatusCode= new OptionSetValue(-1)});
推荐阅读
- azure-devops - 将包推送到内部 Azure Dev Ops 包源时的身份验证问题
- python - 将整数数组转换为二进制表示矩阵
- python - AttributeError:“lxml.etree.QName”对象没有属性“resolve”
- azure - Azure CosmosDB 准时触发到有效期限
- cmd - Windows机器上的git-lab-runner中的命令不起作用
- unity3d - 当 AppendStructuredBuffer 在计算着色器中溢出时会发生什么?
- sql - 无法合并 2 个表
- python-3.x - \n 在 Python 3 中的混淆
- python - 如何将 Pandas 列切片转置并插入行切片?
- xml - 如何以与 androidstudio 中相同的大小显示我的按钮和图像视图?