Email sent based on Catalog Task variable changes

jacobpeterson
Mega Expert

Hello all,

I have created a variable specific to one catalog item with a drop down of selections. When a specific selection is chosen and the form is saved I want it to trigger an email to the user in the variable "Requester". The emails will be specific to which option they chose and they can continue to chose new options and save the form sending different emails.

What would be the best approach to achieving this?

Thank you!

3 REPLIES 3

Madhu27
Tera Expert

you have achieve this by writing a 'update', 'insert' business rule on SC_TASK table. By calling mail script you can send appropriate email to requester.


Uncle Rob
Kilo Patron

I'd be interested in a higher level view to see if this is the best mechanical fit for the business need.



From a purely mechanical standpoint, you have a challenge in that the notification record can't use variables in conditions.   And probably cant target them in the send-to fields either.   This means you'll need a business rule to evaluate updates, then fire a custom event.   You fire over the requester as a parameter of the event.   Then you build your notification as being event driven, rather than condition driven.



find_real_file.png


Solution Archit
Tera Contributor

This can be achieved by adding a business rule on sc_task table.

Table: sc_task

Before update and add a filter for the catalogitem this functionality to run on

Script:

(function executeRule(current, previous /*null when async*/ ) {
    // Add your code here
   if (current.variables.<variable_name>.changes()) {
        gs.eventQueue('eventname', current, recipient 1, recipient 2);
    }
})(current, previous);

 

And make sure the event and emails are on sc_task table to trigger the notification.

 

This works for me in Tokyo release.

 

If this answers your question, please mark the answer as helpful