How can I add a mail script to the subject line?

josenava
Tera Expert

Hello experts please I need your help, how can I create a mail script that can be added to the subject line of an email? 

There are 2 fields in the incident form:

*Subcategory

*Missing CI

the subject line needs to change based on the user selection:

if the user clicks on CI Missing, the the subject field needs to have the subcategory field information:

find_real_file.png

Subject:High Priority Incident - INC0010616 - Antivirus

If the user selects a CI instead, then the subject line needs to have the CI name, not the subcategory field information:

find_real_file.png

Subject: High Priority Incident - INC0010616 - MacBook Air 13''

Thank you

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

You can't add a mailscript to the subject, but you can call a mailscript in the body and set the subject. 

Just write your logic to create the string you want to set, then in the mailscript call: 

var str = 'your subject';
email.setSubject(str);

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

4 REPLIES 4

Michael Jones -
Giga Sage

You can't add a mailscript to the subject, but you can call a mailscript in the body and set the subject. 

Just write your logic to create the string you want to set, then in the mailscript call: 

var str = 'your subject';
email.setSubject(str);

I hope this helps!

If this was helpful or correct, please be kind and remember to click appropriately!

Michael Jones - Proud member of the CloudPires team!

I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Hi Michael, how can I add current year to the subject. Example: Your subject + 2025

Something like this: 

var str = 'your subject' + ' ' +  new GlideDateTime().getYearLocalTime();
email.setSubject(str);
I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Hi Michael,

Thanks for your response and expertise. I am very grateful for your help. Thank you, Michael!