且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-09-05 23:13:12

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

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

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

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

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.


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

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

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

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:

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