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.

  • 相关阅读:
    Spark之 SparkSql整合hive
    Spark之 使用SparkSql操作Hive的Scala程序实现
    Spark之 RDD转换成DataFrame的Scala实现
    Spark之 SparkSql、DataFrame、DataSet介绍
    Spark之 RDD
    Spark scala和java的api使用
    设计模式之四观察者模式
    设计模式之三静态代理模式
    设计模式之二装饰者模式
    设计思想之二面向接口编程
  • 原文地址:https://www.cnblogs.com/lingdanglfw/p/15068762.html
Copyright © 2011-2022 走看看