Send custom approval notification from workflow instead of OOB notification

Aaron Munoz
Tera Guru

I have a table that extends task, with a workflow that triggers approval requests. I want to send a custom email notification for the approver. The one I created is triggered from the same event (approval.inserted) as the OOB notification for approval requests, but now both are getting sent. The OOB notification doesn't have a weight, so I can't use that to avoid sending it.

The only way I got it working is by applying a filter condition on the OOB notification, but this is not ideal. The other solution I can think of is using a "Run Script" activity that creates the approvals but fires a custom event, though this may be difficult to reverse-engineer from the "Approval - User" activity. Is this the best approach, or is there a better way to avoid changing the Out Of Box notification?

1 ACCEPTED SOLUTION

Aaron Munoz
Tera Guru

For future reference, here is what's needed to fulfill this requirement:

  1. Create a new event in the event registry, like u_custom_task.approval.inserted
  2. Create a new notification that is triggered when the your event is fired
  3. Modify the OOB business rule called "Approval Events (Task)" and in line 40 add two lines of code like the following
       else if (current.sysapproval.sys_class_name == "u_custom_task")
       event = "u_custom_task.approval.inserted";

The steps above should be enough to add only one custom approval notification. You may want to make this extensible by creating a table that matches your custom events with your custom tables, and in the business rule calling a script include that queries that table.

View solution in original post

11 REPLIES 11

I want to trigger two custom notifications. I've also added the create event activity in the workflow to trigger those notifications, but only OOB notification got sent to the user.

I am able to send one custom notification through the steps that you have provided.

Can you please suggest me what to do in this case, as I want to send two notifications through the two workflows.

In my original reply I had suggested creating a table to keep track of all the different custom approvals, but with the current licensing model I would instead keep all logic inside a script include where a function takes the name of a task table as a parameter and returns the custom event. Let's say you call your script include ApprovalNotificationMapping. Then you would use the following in the business rule instead of the code in my original reply:

else event = new ApprovalNotificationMapping.returnEvent(current.task_type);

The function in the script include could be something like this:

returnEvent: function(task_type){

if (task_type == "u_custom_task") return "u_custom_task.approval.inserted";

else if (task_type == "u_custom_task_2) return "u_custom_task_2.approval.inserted";

},

osni seca
Kilo Expert

Hi Aaron

I'm trying to accomplish similar thing and I have a question in regards to the line of code:

 

So i created an event called "u_second_approval.inserted". So, following your code statement mine would something like this:

 

else if (current.sysapproval.sys_class_name == "Not sure what put in here!!!");

event = "u_second_approval.inserted";

 

OS

Charu
Kilo Contributor

You have to put the table name there.

I hadn't noticed this follow-up question I missed. Thanks Charu!