Add info to subject with Email Script in Email Client Template (email action on a Change record)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hello there,
I am trying to run an email script to add the current month to the subject, but it won't work.
Any idea why ?
I'm calling my email script in the HTML field of the Email Client Template. It should be running when a user wants to send an Email with the email feature on a Change record.
If it is impossible with this method, is there any workaround to achieve what I want to do ?
Thank you in advance.
Dorian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @Dorian MOREL ,
Try this:
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var gdt = new GlideDateTime(); //November
var current_month = gdt.getMonth(); // returns number
email.setSubject("Test Subject : " + months[current_month - 1]);
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
28m ago
Hi @Dorian MOREL - You would get the current email subject with email.getSubject() With your code, something like this should work:
var months = ["JANVIER", "FEVRIER", "MARS", "AVRIL", "MAI", "JUIN", "JUILLET", "AOUT", "SEPTEMBRE",
"OCTOBRE", "NOVEMBRE", "DECEMBRE"
];
var nb_month = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
var gdt = new GlideDateTime();
var month = gdt.getMonth().toString();
email.setSubject(email.getSubject() + " " + months[nb_month.indexOf(month)].toString());
Keep in mind that you can get the current month name from GlideDate if you want to skip the mapping:
var date = new GlideDate();
var month = date.getByFormat("MMMM");
