【问题标题】:Dynamics CRM 2016 on-premise Disable a user does not workDynamics CRM 2016 on-premise 禁用用户不起作用
【发布时间】:2019-02-21 02:16:06
【问题描述】:

我们升级到 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 |活动 ID:ad01991a-c02a-4f1e-9db1-3a936a432752 | VersionedPluginProxyStepBase.Execute ilOffset = 0x64

Web 服务插件在 SdkMessageProcessingStepId 中失败:{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(对象目标,对象 [] 参数,签名 sig,布尔构造函数) 在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象 obj,对象 [] 参数,对象 [] 参数) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,Object[] 参数,CultureInfo 文化) 在 System.Web.Services.Protocols.LogicalMethodInfo.Invoke(对象目标,对象 [] 值) 在 Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider 服务提供者) 在 Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext 上下文) 在 Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext 上下文) 内部异常:Microsoft.Crm.CrmArgumentException:-1 不是 Id 邮箱上的有效状态代码。 在 Microsoft.Crm.BusinessEntities.StatusCodeValidator.Validate(EntityMetadata entityMetadata,Int32 stateCode,Int32 statusCode,Guid businessEntityId) 在 Microsoft.Crm.BusinessEntities.BusinessProcessObject.SetState(BusinessEntityMoniker moniker,Int32 newState,Int32 newStatusCode,BusinessEntity originalEntity,ExecutionContext 上下文) 在 Microsoft.Crm.BusinessEntities.BusinessProcessObject.SetState(BusinessEntityMoniker moniker,Int32 newState,Int32 newStatusCode,ExecutionContext 上下文) 在 Microsoft.Crm.ObjectModel.MailboxServiceInternal1.SetState(BusinessEntityMoniker moniker, Int32 newState, Int32 newStatusCode, ExecutionContext context) at Microsoft.Crm.ObjectModel.SystemUserServiceInternal1.SetMailboxState(BusinessEntityMoniker moniker,Int32 newState,Int32 newStatusCode,ExecutionContext 上下文) 在 Microsoft.Crm.ObjectModel.SystemUserServiceInternal`1.SetState(BusinessEntityMoniker moniker,Int32 newState,Int32 newStatusCode,ExecutionContext 上下文) 在 Microsoft.Crm.ObjectModel.SystemUserService.Microsoft.Crm.Sdk.IStateful.SetStateStatus(BusinessEntityMoniker,Int32,Int32,ExecutionContext) 内部异常:System.ArgumentException:-1 不是具有 Id 的邮箱上的有效状态代码。 参数名称:stateCode

所以我尝试先停用用户邮箱,但没有帮助。还是同样的问题。有人遇到同样的问题并以某种方式解决了吗?

【问题讨论】:

    标签: c# dynamics-crm


    【解决方案1】:

    尝试使用 IOrganizationService.Update() 方法更新 statecode/statuscode 字段。

    _service.Update(new SystemUser{ Id = <systemuserid>, StateCode= new OptionSetValue(1), StatusCode= new OptionSetValue(-1)});
    

    【讨论】:

    • 我试过了,但是 SystemUser 没有 StateCode 也没有 StatusCode。所以我在 SystemUser 上没有该选项,并且使用后期绑定不起作用,CRM 只会响应:''systemuser' 实体不包含 Name = 'statecode' 的属性。'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-01
    • 2010-09-09
    • 2017-02-23
    相关资源
    最近更新 更多