Email script is not working in the subject
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 07:50 AM
I am calling email script in Notification subject. It is not working in the subject and same script working in the body. PFB script that I am using in email script.
var str = current.short_description.toString();
var str1 = str.slice(0,10);
template.print(str1);
//email.setSubject('Information request '+current.number+' '+str1);
email.setSubject is working in subject but in that case I need to create separate email script for each notification.
Thanks & regards,
Brijmohan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 07:55 AM
Hi Brijmohan,
Can you try adding the email.setSubject() just before you set the description in the mail script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 08:44 AM
Hi @Jaspal Singh , Thanks for your response but I don't want to use email.setSubject() because If I will use it i need to create more then one email script. I am just want to call email script in subject so I can only restrict 60 char like below.
var str = current.short_description.toString();
var str1 = str.slice(0,60);
template.print(str1);
but this code is not working it is giving in subject ${mail_script:script_name} without email subject.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 09:00 AM
Hi @Brijmohan,
You need to use email.setSubject(); method to set/override the subject using email scripts. with out setSubject() will not be able to set subject in notifications.
Try this updated scripts:
var str = current.short_description.toString();
var str1 = str.slice(60);
// template.print(str1);
email.setSubject('Information request ' + current.number + ' - ' + str1);
If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 11:46 PM
Hi @Brijmohan,
Have you looked into my comments? let me know if have any issues so far.
If my response helps to solve your issue. Kindly mark it as helpful/correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar