• SAP Cloud for Customer使用工作流(workflow)实现邮件自动通知功能


    In release 1708 the Recipient Determination to “Reporting Line Manager” in Opportunity is available:

    However for Account application, there are only six available determination rules available in standard.

    Suppose we need to support the following scenario:

    Max is Jerry’s manager. When Jerry has changed a given kind of Account in system, Max will get an email notification triggered by workflow. The general idea to fulfill this requirement is to introduce a logic which could automatically make Max as one member in Account Team table in Account TI by a small development in Cloud Application Studio, so that the existing functionality provided by Workflow framework could be leveraged to send notification.

    Here below is the solution.

    (1) Create a new custom Party Role Code and define it as Recipient determination in Workflow rule edit UI by following this blog Custom recipient determination in workflow rule done on Account BO.
    Of course you can also use standard role code.

    (2) Create a beforeSave script file on Root node of Customer Business Object:

    import ABSL;
    import AP.PC.IdentityManagement.Global;
    
    var managerExists = this.CurrentEmployeeResponsible.Where(x=>x.PartyRoleCode.Contains("ZJE"));
    if( managerExists.Count() <= 0){
      var queryByIdentityUUID = Identity.QueryByElements;
      var queryByIdentityUUIDParameter = queryByIdentityUUID.CreateSelectionParams();
      var queryByEmployeeBPUUID = Employee.QueryByIdentification;
      var queryByEmployeeBPUUIDParameter = queryByEmployeeBPUUID.CreateSelectionParams();
      var id = Context.GetCurrentIdentityUUID().content;
      queryByIdentityUUIDParameter.Add( queryByIdentityUUID.UUID.content, "I", "EQ", id.ToString() );
      var result = queryByIdentityUUID.Execute(queryByIdentityUUIDParameter);
      var first = result.GetFirst(); // points to identity instance
      var person = first.Person;
      var bpUUId = person.UUID.content;
      queryByEmployeeBPUUIDParameter.Add( queryByEmployeeBPUUID.UUID.content, "I", "EQ", bpUUId.ToString());
      var employeeQueryResult = queryByEmployeeBPUUID.Execute(queryByEmployeeBPUUIDParameter);
      var EmployeeQueryResultCurrent = employeeQueryResult.GetFirst();
      var assignedOrg = EmployeeQueryResultCurrent.OrganisationalUnitAssignment.GetFirst();
      var org = assignedOrg.ToRoot;
      var manager = org.Manager.GetFirst();
      firstCommon.CustomExtension = manager.EmployeeUUID.content;
    
      var newNode: elementsof Customer.CurrentEmployeeResponsible;
      newNode.EmployeeUUID.content = manager.EmployeeUUID.content;
      newNode.PartyRoleCode = "ZJE";
      this.CurrentEmployeeResponsible.Create(newNode);
    }
    

    The idea of this code: first check whether the line manager is already maintained as one member of current Account team ( in this example I use a custom Party Role Code ZJE to represent Line Manager role ), if not, then query the corresponding line manager of current logon user and create a new Account team member dynamically.
    In the runtime, the behavior is that once Jerry creates a new account, Jerry’s manager Max will automatically become as one Account Team member and received a notification Email:


    要获取更多Jerry的原创文章,请关注公众号"汪子熙":

  • 相关阅读:
    POJ3311Hie with the Pie(floyd传递+DP,状态压缩)
    POJ1185炮兵阵地(DP状态压缩)
    POJ3254Corn Fields (状态压缩or插头DP)
    eBPF Tracing 入门教程与实例
    因为 Java 和 Php 在获取客户端 cookie 方式不同引发的 bug
    DRDS 数据恢复重磅发布,全方位保障您的数据安全
    前沿 | 全球最具影响力开源数据库峰会开幕在即 阿里云精彩议题先睹为快
    MaxCompute 预付费标准版VS套餐版
    DTCC 2019 | 深度解码阿里数据库实现 数据库内核——基于HLC的分布式事务实现深度剖析
    从 Apache ORC 到 Apache Calcite | 2019大数据技术公开课第一季《技术人生专访》
  • 原文地址:https://www.cnblogs.com/sap-jerry/p/13576531.html
Copyright © 2020-2023  润新知