How to send more than 2 parameters in an event?

prashant_gadgil
Tera Contributor

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

 

 

1 ACCEPTED SOLUTION

Brent Sutton
Mega Sage

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.

View solution in original post

6 REPLIES 6

Brent Sutton
Mega Sage

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:

template.print(myParameters.first_name);
template.print(myParameters.last_name);
template.print(myParameters.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.

ARG645
Tera Guru

Prashant,

An event can take only 2 parameters. However, you can pass objects as a parameter, an object can contain all your required data. For example say in the Business Rule script you can do something like 

gs.eventQueue("eventName",current,previous,'');
//Param1: eventName - Name of the event
//Param2: current   - GlideRecord Representation of the record in subject
//Param3: Previous  - Event Paramenter 1
//Param4: NULL      - Event Paramter 2

 In the notification email scripts, get the values from current and previous and manage your logic. Hope you get lucky. 

Thank you,

Aman Gurram

somehow passing current and previous as param1 and param2 did not work. I also tried JSON.stringify(current) etc..

Brent Sutton
Mega Sage

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.