Why does Email Script return Incident Number for incidents, but returns the Short Description for project tasks?

JR42
Giga Guru

Hello.  We have an Email Notification (Activity Stream @Mention Email) which uses an Email Script  (ng_activity_mention_body).

The same notification and email script are used for Incident records and Project Task records.

We have noticed that when this notification is sent for an Incident, the incident number is included in the Subject and Body.  However, when the notification is sent for a Project Task, the Short Description from the project task is used, in place of the number.

We would like the number to be displayed in the notification for project tasks, just as it is for Incidents.

 

Example notification for Incident:
Subject: You have been mentioned in INC0000001
Body: You have been mentioned by Joe in the Incident record INC0000001

Example notification for Project Task:
Subject: You have been mentioned in Customer Go-Live - Add blade servers
Body: You have been mentioned by Joe in the Project Task record Customer Go-Live - Add blade servers

 

Here is the Email script: ng_activity_mention_body

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

    var result = new ActivityMentionEmailValues().getEmailValues(current.table, current.document);
    if (result) {
        result = JSON.parse(result);
        email.setSubject(gs.getMessage("You have been mentioned in {0}", result.subjectText));
        template.print("<p style='color: #424E5B;margin: 0 0 12px;line-height: 26px;margin-bottom: 12px'>");
        template.print(gs.getMessage("You have been mentioned by {0} in", current.user_from.name));
        template.print("&nbsp;<a>" + result.linkText + "</a></p>");
    }

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

 

Can anyone point me in the right direction?

1 ACCEPTED SOLUTION

That is why I have asked you to verify Dictionary Override for short_description field. 

See the below images for reference;

As you can see that display value for Number field is set to true for vtb_task table.

find_real_file.png

 

But still I am getting short_description as display value in my script result.

Script:

find_real_file.png

Output:

find_real_file.png

Record:

find_real_file.png

 

This is because Override display value for short_description is set to true.

find_real_file.png

 

If I set it to false then I will get Number.

find_real_file.pngfind_real_file.png

By the way the image you have shared is not visible.

Hopefully, it will help you understand.

View solution in original post

9 REPLIES 9

Mohith Devatte
Tera Sage
Tera Sage

Hello Justin,

i think the values are returning from the script include ctivityMentionEmailValueS 

I think in the script include you must be returning the display value of the field in which for incident the display value is set to true for number field  in dictionary of incident table which is returning correctly .

It might be a case where for project task table short description field is set to display true which is inturn getting the short description as a result .

Please check that and change un check the display true to project task short description and check  it to true  for project task number field in project task table dictionary

please mark my answer correct if it helps you

Muhammad Khan
Mega Sage
Mega Sage

Hi Justin,

 

Your are basically using the following Script Include in your mail script which is returning result in string of JSON.

find_real_file.png

This script include is setting values using getDisplayValue(). So, as per my understanding, the display value column for Incident table is Number while for Project Task it could be Short Description.

 

Hopefully, this will give you a direction to debug.

ShubhamGarg
Kilo Sage

Hello Justin,

Can you please try to print the value of result before and after parsing line and check -

 result = JSON.parse(result);

Basis on this you can look up to the value being passed through result.subjectText in the next line.

Let me know if issue still persists.

Mark this as helpful if it helps.

 

Kind Regards,

Shubham

Hi @Shubham Garg, I've not been able to figure out how to test and print results of code.  Do you have any links that I could study through to learn this process?