How to use an If statement in email scripts to evaluate Incident State

Adam Robbins1
Mega Guru

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

1 ACCEPTED SOLUTION

Please try current.state.getDisplayValue() ?


View solution in original post

6 REPLIES 6

Thank you!



I adjusted my variable as follows and it worked



var strState = current.state.getDisplayValue();


Patrick Fedigan
Giga Guru

Hello Adam,



Please try these recommendations:



  • .trim() on the strings
  • .valueOf() to convert the string to a primitive
  • use '===' instead of '==' ('===' will not do type conversion)


Cheers,