- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2019 01:18 PM
In my use case, I have to send an email notification when a record is updated in a custom table.
The email notification body needs to contain before and after update values of multiple columns (e.g. 10 columns) of the record.
What is the best way to achieve this?
Currently I can send an event form inside the update business rule on that table. But with the event I can pass only param1 and param2 which can be embedded into the email notification which is trigger by that event. is there a way to send more than 2 (e.g. 20) params) to address the above use case?
Prashant
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2019 01:45 PM
Pass your parameters in a JSON object and then refer to them in an email script.
Add value/pairs to variable in a JSON object.
var myParameters = {"first_name": "John","last_name": "Doe","address": "1 Abbey Road, London"};
Refer to object in Email Script:
//extract details from JSON object
var firstName = event.parm1.first_name.toString();
var lastName = event.parm1.last_name.toString();
var address = event.parm1.address.toString();
//print results
template.print(firstName);
template.print(lastName);
template.print(address);
Hope this makes sense
Brent
P.S. If my suggestion helped then please mark as helpful and/or correct so other community members can benefit from this information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2019 09:27 AM
the below worked:
In the business rule:
var previousValues = {};
previousValues.name = previous.name.toString();
prevousValues.email = previous.email.toString();
var currentValues = {};
currentValues.name = current.name.toString();
currentValues.email= current.email.toString();
var parm1 = JSON.stringify(previousValues);
var parm2 = JSON.stringify(currentValues);
gs.eventQueue("myEvent", current, parm1, parm2);
and in the email notification script in the email handling this event:
var previousValues = JSON.parse(event.parm1);
var currentValues = JSON.parse(event.parm2);
template.print("Old Name = " + previousValues.name + "<br>");
template.print("New Name = " + currentValues.name + "<br>");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2020 01:34 AM
Hi Prashant,
I have a similar situation of sending previous and current values of 16 fields , Need to send only updated values . I am thinking of sending all previous values in a array and parse them in mail script and print them using switch Case.
Can you please provide the approach you took or a sample script, thanks