zoukankan      html  css  js  c++  java
  • Display different Business Process Flow based on user security role in D365 CE /PowerApps

     

     

    In this blog, we will look at how we can display different business process flow based on user security role in D365 CE.

    Use Case:

    In my example, I have two Business Process Flow on Opportunity entity.

    • Opportunity Sales Process 
    • Manager Process 

    Users with a “Custom Project Management Role” security role can only see Manager Process Business Process Flow. 

    Implementation:

    var formCustomizations = {
    
        displaybpf: function (executionContext) {
    
            var formContext = executionContext.getFormContext();
            var managerRoleId = "520359B5-FF61-EB11-A812-00224806B6E3"; //GUID of Manager Role
            var userSettings = Xrm.Utility.getGlobalContext().userSettings;
            var userRoles = userSettings.securityRoles;
            var userHasRole = false;
    
            userRoles.forEach(roles => {
                if (roles.toLowerCase() === managerRoleId.toLowerCase()) {
                    userHasRole = true;
                    return;
                }
            });
    
            if (userHasRole === true) {
                formContext.data.process.setActiveProcess("b7363263-2265-eb11-a812-000d3a3759c1"); //Pass the GUID of BPF to show when user has security role
            }
            else {
                formContext.data.process.setActiveProcess("3e8ebee6-a2bc-4451-9c5f-b146b085413a"); //Pass the GUID of other BPF to show when user does not have security role
            }
        }
    }
    • register an Event On Form Load, as shown below:

    Testing:

    User with Manger Role:

    User without Manager Role:

    Note:

    1. Make sure you have added both the Business Process Flow in the Model-driven app.

  • 相关阅读:
    java的语法基础(二)
    MyBatis 的好处是什么?
    python中字符串的编码和解码
    Spring的简介和优点?
    相对于Statement,PreparedStatement的优点是什么?
    MyBatis 的好处是什么?
    .final finally finalize区别
    final类有什么用
    web广泛用到的技术:
    JDK,JRE,JVM三者的关系
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/15068762.html
Copyright © 2011-2022 走看看