Stopping Deactivation of Records in Dynamics 365
There was a question recently on CRMUG about how to modify security to prevent users from Deactivating Contacts.
In Dynamics 365, the security roles can be configured (and is best practice) to prevent users from deleting records.
Removing Delete Option Generally a good idea.Deactivating records is generally a safer process as it can be reversed and no information is lost. However, there may be processes and reports that will only pull data from active records so it may be a business requirement to prevent users from deactivating records.
Since “deactivating” a contact is really just modifying a field value (status “active” to “inactive”) the privilege is controlled by the “edit” permission. Obviously users need to add and edit records!
One solution is to use the Ribbon Workbench and edit the menu to hide/show the deactivate button based on security roles. This is a viable solution but requires some level of JavaScript and knowledge of the Ribbon workbench, not hard but not exactly a picnic either.
Workflow Solution
Another solution would be to utilize workflow to prevent a user from deactivating a record.
The first thing would be to add a boolean field to the system user record to effectively set the security privelege of being able to deactivate a record (or not). In my example, I will add a restriction on deactivating contacts.
For the User record, I will add a new “permission” boolean field. I also enabled field security to prevent modification but unauthorized users.
Once the field is added to entity, it will need to be placed on the form.
The next step will be to create a synchronous workflow that is triggered anytime the record status changes. The workflow will check to see if the record’s status is “inactive” and if the “Last Modified User” actually has the permission to deactivate the record.
The workflow needs to be synchronous because we want the user to know immediately that they are not allowed to deactivate the contact.
The first condition to check would be to see if the status has been set to “inactive” and also to check if the last modified by user has the permission to deactivate records.
If the conditions are met, the next step is to set the contact “back” to being active.
Once the contact is set back to active, it is courtesy to let the user know (so they don’t think that they are going crazy).
How come the Deactivate didn’t work?Use the “Cancel Workflow” step.
The reason why we want the “cancel workflow” is so that an error message will be surfaced to the end user.
In the “Set Properties” you can put in your own custom error message.
Save and activate the workflow.
You will then need to set the appropriate “permission” on the user record.
You will also need to setup a Field Security profile so that users will be able to “read” the value from the user records. You can add the default Business Unit team to this profile to easily provide this access.
Now, a user will still be able to attempt to “deactivate” a record…
However, once the user continues, a Business Process message will appear (showing the custom error message)
While this might not be the most elegant solution, it will serve the purpose.
What it also highlights is yet another example of the possibilities of the configuration options using Dynamics 365.
posted on 2021-10-07 12:27 lingdanglfw 阅读(34) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?