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

Tony Chatfield1
Kilo Patron

Hi,

I think a simple solution is better long term, for both stability and ease of further enhancement.
You can possibly create your own sysevent via the system registry and then trigger this via a Notification > Create event activity in your workflow, this way approval.inserted is not utilized and you shouldn't need additional scripts.

Otherwise, if you don’t want to make a lot of changes to OOB configuration like notifications, perhaps just disable the OOB record completely and create replacements. When it comes to validating upgrades, confirming that the ‘active’ state of an OOB notification hasn’t been reverted is a lot simpler than checking\confirming the configuration of individual custom changes.

Regards Tony

Kalaiarasan Pus
Giga Sage

I would edit the original out of box notification in case you are not using it in any of the process. Even if you disable it and create a copy, the upgrade is going to skip it in any case. There won't be any significant update on a notification if even miss checking it during upgrade.

Apurva Malewad1
Kilo Guru

Hi,

If you want to send custom notification only through event then you can Inactive OOTB notification so that it won't be triggered only custom will be triggered.

 

Please mark my answer correct/helpful if it helps you to find the solution.

 

Thanks and Regards,

Apurva Malewadikar

www.DXSherpa.com

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.