请不要在繁忙时候更改用户的业务部门
作者:互联网
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面的微软最有价值专家(Microsoft MVP),欢迎关注我的微信公众号 MSFTDynamics365erLuoYong ,回复390或者20200120可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!
如果你的系统中有些执行耗时的SQL,语句类似如下,也就是更新OwningBusinessUnit字段的值。
exec sp_executesql N'if exists( select top(1) BookableResourceCharacteristicId from BookableResourceCharacteristicBase (nolock) where OwnerId = @OwnerId) update BookableResourceCharacteristicBase set OwningBusinessUnit = @BusinessId where OwnerId = @OwnerId ',N'@BusinessId uniqueidentifier,@OwnerId uniqueidentifier',@BusinessId='C40F411A-C70A-EA11-A85F-000D3A6F652B',@OwnerId='5C81977C-6995-E911-A83B-000D3A5129C5'
如果这个实体启用了公告(Post)功能,那么语句会如下:
exec sp_executesql N'if exists( select top(1) IncidentId from IncidentBase (nolock) where OwnerId = @OwnerId) update IncidentBase set OwningBusinessUnit = @BusinessId where OwnerId = @OwnerId if exists( select top(1) PostRegardingId from PostRegardingBase (nolock) where RegardingObjectOwnerId = @OwnerId) update PostRegardingBase set RegardingObjectOwningBusinessUnit = @BusinessId where RegardingObjectOwnerId = @OwnerId ',N'@BusinessId uniqueidentifier,@OwnerId uniqueidentifier',@BusinessId='C40F411A-C70A-EA11-A85F-000D3A6F652B',@OwnerId='5C81977C-6995-E911-A83B-000D3A5129C5'
这个是啥操作导致的呢?我经过验证,是更改用户业务部门导致的。现在既可以通过命令栏的【更改业务部门】按钮来做,也可以直接更新【业务部门】这个字段。
更改业务部门生成的SQL很多,我猜测每个由用户/团队所有的实体都会去找一找,然后更新下。所以执行的时间会比较长,有可能还会超时。
如果执行超时参考我这篇文章 Dynamics 365执行操作报SQL Server已超时,更改这个超时设置的方法 做个配置修改。
这个与更改负责人的SQL语句不一样,如果设置了分派级联,也会更改子记录的负责人,我这里抓取的SQL如下:
exec sp_executesql N'update [ly_WorkOrderBase] set [OwnerId]=@OwnerId0, [ModifiedBy]=@ModifiedBy0, [ModifiedOn]=@ModifiedOn0, [OwningBusinessUnit]=@OwningBusinessUnit0, [ModifiedOnBehalfBy]=@ModifiedOnBehalfBy0, [OwnerIdType]=@OwnerIdType0 where ([ly_WorkOrderId] = @ly_WorkOrderId0)',N'@OwnerId0 uniqueidentifier,@ModifiedBy0 uniqueidentifier,@ModifiedOn0 datetime,@OwningBusinessUnit0 uniqueidentifier,@ModifiedOnBehalfBy0 uniqueidentifier,@OwnerIdType0 int,@ly_WorkOrderId0 uniqueidentifier',@OwnerId0='5C81977C-6995-E911-A83B-000D3A5129C5',@ModifiedBy0='CAE5E10F-BF1B-E911-A813-000D3A5129C5',@ModifiedOn0='2020-01-20 10:27:16',@OwningBusinessUnit0='D8DEE10F-BF1B-E911-A813-000D3A5129C5',@ModifiedOnBehalfBy0='CAE5E10F-BF1B-E911-A813-000D3A5129C5',@OwnerIdType0=8,@ly_WorkOrderId0='BB3744AC-39C0-E911-A84F-000D3A5129C5' exec sp_executesql N'update [ly_WorkOrderDetailBase] set [OwnerId]=@OwnerId0, [ModifiedBy]=@ModifiedBy0, [ModifiedOn]=@ModifiedOn0, [OwningBusinessUnit]=@OwningBusinessUnit0, [ModifiedOnBehalfBy]=@ModifiedOnBehalfBy0, [OwnerIdType]=@OwnerIdType0 where ([ly_WorkOrderDetailId] = @ly_WorkOrderDetailId0)',N'@OwnerId0 uniqueidentifier,@ModifiedBy0 uniqueidentifier,@ModifiedOn0 datetime,@OwningBusinessUnit0 uniqueidentifier,@ModifiedOnBehalfBy0 uniqueidentifier,@OwnerIdType0 int,@ly_WorkOrderDetailId0 uniqueidentifier',@OwnerId0='5C81977C-6995-E911-A83B-000D3A5129C5',@ModifiedBy0='CAE5E10F-BF1B-E911-A813-000D3A5129C5',@ModifiedOn0='2020-01-20 10:27:16',@OwningBusinessUnit0='D8DEE10F-BF1B-E911-A813-000D3A5129C5',@ModifiedOnBehalfBy0='CAE5E10F-BF1B-E911-A813-000D3A5129C5',@OwnerIdType0=8,@ly_WorkOrderDetailId0='9D460B48-6F3B-EA11-A86F-000D3A6F652B'
标签:业务部门,uniqueidentifier,更改,E911,繁忙,OwnerId,where,000D3A5129C5,ly 来源: https://www.cnblogs.com/luoyong0201/p/Dynamics_365_Do_Not_Change_User_Business_Unit_In_Pea