e-mail notification from an event..

Srikanth Menava
Kilo Sage

I wrote a recurring email - notification. I need a count of the notification in the email body..

To be precise I wrote an email notification that occurs continuously untill a specific condition is met. So, now what i need is to get the number in the email body.. i.e., if the email got triggered for the first time it needs to say 1st notification, and if its for the second time we need to say 2nd notification, so on.,

I hope I am clear, and I will get the answer for this.

1 ACCEPTED SOLUTION

Srikanth Menava
Kilo Sage

I achieved this by using the email scripts.. and using that email script reference in the notification..
here is the script...



(function runMailScript(current, template, email, email_action, event) {




                  // Add your code here


var count = event.parm2.toString();


if(count>0){


template.print("This is "+count+" reminder.");


  }


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



and I called this script in the 'what it will contain' in the notification,



not.PNG


This helped me to achieve the requirment ,,
just in case if anyone have the same requirement.. Hope this will help them..


View solution in original post

18 REPLIES 18

sorry I misheard the question you asked @david, I wrote workflow with the conditions. so it is triggering the event.


If it's a workflow, then why not just store the counter in the scratchpad of the workflow?


Hello Adam,


I am not familiar with a scratchpad of a workflow . can you be detailed about this.


Within a workflow, you can use a 'Run Script' activity and declare or populate workflow scatchpad variables that are available throughout the rest of the workflow. You would just declare it as workflow.scratchpad.variable_name.  



For example:


workflow.scratchpad.counter = 1;



Workflow scratchpad variables


Jon Barnes
Kilo Sage

I would recommend storing a counter on the target record for that notification. So if the notification is for an incident record, create a field that stores the count of the times this notification has triggered, and then increment it each time the event is triggered.



The other option I can think of (and this is not very good) is to count the number of records in the sysevent table that match the event name, and the instance is the same. The issue with this approach is that sysevent rotates every 6 weeks or so, so if these events go on longer than that, the information will not be there anymore. Also, there is a performance concern with querying the sysevent table. So if you try this approach, make sure you have an index on the appropriate fields so that it is   optimized. Again, I don't like this option much, but just trying to give you multiple directions to look.



But the first option is probably the safest.