How to pass event values to the notification?

Sathwik1
Tera Expert

Hi Team,

In a schedule job I had an event, and in the event through array I am passing two numbers... so how can I get those numbers in notifcations.

while(gr.next())
{
arr.push(gr.number);
}
gs.eventQueue('trigger.an.event', gr, arr);

Now arr contain two numbers like.. INC000301, RITM000201..

and I created a notification, in "when send" I selected "Trigger by event" and selected event name...

Now my doubt is in email body how did I get the numbers which was in arr?

can some one please help me..

@Ankur Bawiskar @Jaspal Singh @AnirudhKumar 

 

1 ACCEPTED SOLUTION

Looks okay to me. 

Can you put a Log in your Mail script after line number 6 as below:

gs.info('Value coming in param is ' + getArray);

Please check on what is coming.

Also just to be extra cautious not sure might be the cause, try changing the Name of your email script to something else like as below:

"getDetails"

Also remove the space between the colon and your Mail script name in your notification and write it as below:

${mail_script:getDetails}

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

12 REPLIES 12

@shloke04 can you please help?

Hi,

In order to get your array values which you are passing from your Schedule job is as below:

1) Create a Notification email script and use the below sample script as shown below:

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here
    var getArray  = event.parm1.toString();
	var splitStr = getArray.split(',');
	for(var i=0;i<splitStr.length;i++){
		template.print('Value is '+ splitStr[i]);
	}

})(current, template, email, email_action, event);

This will print array elements and now you can call this Notification email script in your notification using the syntax below:

${mail_script:Notification email script name}

 

Above is a sample script, you can modify it if needed as per your requirement.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Thanks for your response...

In notification I am getting output like below..

${mail_script : triggermailscript}

here "triggermailscript" is my email script name... what's wrong in it?

@Sathwik 

Can you share screenshot of your Notification email script configured and your Notification as well here to help you further.

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Email Script.

find_real_file.png

Notification

find_real_file.png

 

Output

find_real_file.png

Event log : 

find_real_file.png

Tried a lot, but some where it's not working... please help @shloke04