- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 01:36 AM
Hi All,
I am using client template and trying to add a "Fw:" prefix in Subject line using below code. However, below line of code is breaking my script and not overriding the subject. Any suggestions?
email.setSubject("Fw:"+ current.short_description -- current.number);
Below are my script and screenshot for reference.
<mail_script>
var str = " This is my subject line";
email.setSubject(str);
var gr = new GlideRecord('u_test_email');
gr.addQuery('sys_id',current.sys_id);
gr.query();
while(gr.next()){
var action = gr.getValue('u_email_action');
gs.info("Action Value:"+action);
if(action == '1'){
template.print("Inside forward");
}
else if(action == '2'){
template.print("Inside Send");
}
}
</mail_script>
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 03:52 AM
Sorry KS, you are correct, the set subject does not seem to work for email clients, I was testing with a normal notification.
I don't have a solution for that yet, lets wait and see if someone else has an answer, I will also keep looking to see if I can find a way.
Cheers,
Diogo
edit: One way that should work, if you create a field in the form (hidden) and you use ${name_of_field} in the subject it should get the same result, you just have to construct the full subject in that field and then use it in the email client.
You can even do the following have a new field called something like u_forward (string) and then use a business rule to evaluate the conditions and if they are true add the text "Fw:", then in the email client subject you can have " ${u_forward) ${short_description} -- ${number} " , if the u_forward is empty it won't be shown and if it has something it will show. I didn't test this but in theory it should work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 02:24 AM
Try this : email.setSubject("Fw: "+ current.short_description + "-- " + current.number);
You need to add the quotes "--" and the plus sign otherwise it will break.
Cheers,
Diogo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 02:40 AM
Hi Diogo,
I tried then also it's not working. Thoughts??
<mail_script>
var gr = new GlideRecord('u_test_email');
gr.addQuery('sys_id',current.sys_id);
gr.query();
while(gr.next()){
var action = gr.getValue('u_email_action');
gs.info("Action Value:"+action);
if(action == '1'){
template.print("Inside forward");
email.setSubject("Fw: ");
}
else if(action == '2'){
template.print("Inside Send");
}
}
</mail_script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 02:50 AM
Hey KS, I just created a Mail Script that I call in a notification and was able to use this : email.setSubject("Fw: "+ current.short_description + "-- " + current.number); without any problems,
can you put some logs (gs.log("entered the if ")) in you code to see where it's breaking, are you sure it is going inside the if?
Cheers,
Diogo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2017 03:29 AM
Hi Diogo,
Can you pls share your entire script with me. Yes, it's going in an If loop and printing "Inside forward" but after that script brakes.
Also, I am using Client templates for notification.
Thanks In Advance