Case Notification when case updated by customer

MStritt
Tera Guru

I'm creating a notification on the Case table, that will send a notification when a case has been updated by the customer. In the 'What it will contain' portion of the notification, I'd like to include the most recent update made by the customer. Currently, I've added the 'Additional comments' variable, but it displays all additional comments in the case. I only want to show the most recent additional comment by the customer, that triggered the notification.

2 ACCEPTED SOLUTIONS

Nakka Bhavani S
Tera Expert

Hello MStritt,

 

You need to use email script to achieve this requirement.

 

Please follow the below steps.

1. Create a Email notification script and add the below script.

Lets assume the name of this script is : case_email_notification

 

var latestCom = new GlideRecord('sys_journal_field');   // Sys Journal is the table which contains all work notes and comments
latestCom.addEncodedQuery('element_id=' + current.sys_id);  //no need to change this
latestCom.orderByDesc('sys_created_on');
latestCom.setLimit(1);  // this will ensure to pick the latest comment made on the case
latestCom.query();
if (latestCom.next()) {
template.print('<p><font size="6" color="#808080" face="helvetica">');
template.print(latestCom.value);   // printing the latest comment. no need to check this field until unless you modified the value field in Sys Journal table(Which I doubt)
template.print('</font></p>');

 

2. Open your notification and add this Email notification script in the message HTML like below:


 

${mail_script:case_email_notification} .

 

It will fix your issue. Check and let me know if it fixed your issue or not.

 

Thanks,

Bhavani.

 

 

View solution in original post

@MStritt I'm surprised you didn't accept my solution, Basically you don't need to gliderecord journal table, you can simply do like below. Can you accept my solution as well ?

Email script

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

	template.print('Comments '+current.comments.getJournalEntry(1));

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

And in notification 'What will contain' just call script

${mail_script:test123}

Please hit like and mark my response as correct if that helps
Regards,
Musab

View solution in original post

8 REPLIES 8

Hello MStritt,

 

You have to keep the Updated checked. When you said "every time the case is updated", you mean if you make any update like updating assigned to, changing short description or description? If you are receiving email for these updates as well, then 

 

In Email Notification definition below inserted and updated check boxes you have a condition builder. In that you need to set an condition as below 

Worknotes changes / Additional comments changes

 

In this way system will trigger emails only when there is a update made on work notes/ additional comments only and not triggers emails if there are any changes made on cases.

 

Please check and let me know whether this answers your query or not.

 

Thanks,

Bhavani.

 

You have to keep the Updated checked. When you said "every time the case is updated", you mean if you make any update like updating assigned to, changing short description or description?

<Correct>

 

Unfortunately, I don't want a notification even if a work note (internal) is made. Or, additional comment if it's made by the agent. Only when the customer makes an update (additional comment). 

 

customer_updated is Yes.

In general cases will be updated by respective assignment group members / subject person only.

 I am not sure how many of your customers will update cases(I am assuming this number is big). If you could provide more information on this, it would be good.

 

If more customers will update cases regularly then you need to find a common role or any other property to use it in condition builder.

I think I just need to change the condition from 'customer updated is Yes' TO 'customer updated changes to Yes'.