如何在 Dynamics CRM 2016 v8.2 中使用 javascript 在运行时检查用户权限?
How to check user privilege at runtime using javascript in Dynamics CRM 2016 v8.2?
我需要在 运行 时检查用户权限。
场景:User1 创建了记录,并且它分配给 user2,user1 的记录现在将是只读的。所以 user1 没有访问该特定记录的权限。那么我们可以检查 user1 的 运行time 权限吗?
我知道这是 的后续问题,您需要一种变通方法来识别表单模式 - 当用户具有高于用户级别的读取权限但具有用户级别的编辑权限时,如 CRM 2016 错误无法将表单类型分类为只读与更新。
您有多种选择,例如,在表单中选择一个字段以检索该特定字段的 canRead 权限、canUpdate 访问级别以及决定您要执行的操作。
Xrm.Page.getAttribute("field_name").getUserPrivilege();
I think it is a bug, as it was working as expected from CRM 2011 until CRM 2015. The workaround we used is that, if the form type is 2, we are making another JavaScript Ajax call to check the user permission on the record, if it is read, then we consider the form is read-only, if it is write, then the form is in update mode.
Of course, this solution adds a performance cost to the form load, but we find it good for our case.
Another workaround, I think I saw it in Whosebug, was that you looking for a field on the form that you know it should be editable in the write mode, and check if it is editable or read-only, but we didn't try this solution.
我需要在 运行 时检查用户权限。
场景:User1 创建了记录,并且它分配给 user2,user1 的记录现在将是只读的。所以 user1 没有访问该特定记录的权限。那么我们可以检查 user1 的 运行time 权限吗?
我知道这是
您有多种选择,例如,在表单中选择一个字段以检索该特定字段的 canRead 权限、canUpdate 访问级别以及决定您要执行的操作。
Xrm.Page.getAttribute("field_name").getUserPrivilege();
I think it is a bug, as it was working as expected from CRM 2011 until CRM 2015. The workaround we used is that, if the form type is 2, we are making another JavaScript Ajax call to check the user permission on the record, if it is read, then we consider the form is read-only, if it is write, then the form is in update mode.
Of course, this solution adds a performance cost to the form load, but we find it good for our case.
Another workaround, I think I saw it in Whosebug, was that you looking for a field on the form that you know it should be editable in the write mode, and check if it is editable or read-only, but we didn't try this solution.