- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2017 01:58 PM
Hi,
I am also struggling with an if statement in the email scripts. I read this post, but wasn't able to resolve my issue: Struggle with 'if' statement in email script
I am trying to get to get certain text to show only if State = Resolved. I have tried many different combinations of if (state == 'Resolved') even putting the values into variables and then comparing the variables. I know the if statement is at lease making an evaluation, because it does print the horizontal line in the else section. I've even used template.print to show the 2 variables and both do say Resolved, but for some reason the if doesn't think that they are equal.
If you have found something that works, please let me know.
Thank you,
Adam Robbins
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2017 02:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2017 02:06 PM
On the state field is the value of resolved state 'resolved'?
Think out of the box they assign numbers to the state and only the label has text

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2017 02:06 PM
Can you post your email script. It should be current.state=='Resolved' I think
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2017 02:13 PM
Here is what I currently have:
(function runMailScript(current, template, email, email_action, event) {
var strState = '${state}';
var strResolved = 'Resolved';
template.print('<hr><p><font size="4" color="#999999" face="helvetica"><strong>');
template.print(gs.getMessage('State') + ': ' + '</strong>${state}<strong><br><br>');
template.print('1' + strState + '111' + strResolved + '1<br>' );
template.print(gs.getMessage('Comments') + ':');
template.print('</strong></font></p>');
template.print('<p><font size="3" color="#808080" face="helvetica">' + current.comments_and_work_notes.getJournalEntry(1) + '</font>');
if (strState === strResolved){
template.print('</p><p><font size="4" color="#999999" face="helvetica"><strong>');
template.print(gs.getMessage('Close Code & Notes') + ': ' + '</strong>${close_code}<strong>');
template.print('</strong></font></p>');
template.print('<p><font size="3" color="#808080" face="helvetica">' + gs.getMessage('${close_notes}') + '</font><hr></p>');
}
else {
template.print('<hr></p>');
}
})(current, template, email, email_action, event);
Here is the result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2017 02:17 PM
Please try current.state.getDisplayValue() ?