<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question How to use an If statement in email scripts to evaluate Incident State in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501209#M72988</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am also struggling with an if statement in the email scripts. &amp;nbsp; I read this post, but wasn't able to resolve my issue: &lt;A title="Struggle with 'if' statement in email script" __default_attr="928404" __jive_macro_name="message" class="jive_macro jive_macro_message" data-orig-content="Struggle with 'if' statement in email script" data-renderedposition="52_709.421875_271_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=07f0dfa9dbdcdbc01dcaf3231f96190e"&gt;Struggle with 'if' statement in email script&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get to get certain text to show only if State = Resolved. &amp;nbsp; I have tried many different combinations of if (state == 'Resolved') even putting the values into variables and then comparing the variables. &amp;nbsp; I know the if statement is at lease making an evaluation, because it does print the horizontal line in the else section. &amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have found something that works, please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Adam Robbins&lt;/P&gt;</description>
    <pubDate>Wed, 20 Sep 2017 20:58:41 GMT</pubDate>
    <dc:creator>Adam Robbins1</dc:creator>
    <dc:date>2017-09-20T20:58:41Z</dc:date>
    <item>
      <title>How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501209#M72988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am also struggling with an if statement in the email scripts. &amp;nbsp; I read this post, but wasn't able to resolve my issue: &lt;A title="Struggle with 'if' statement in email script" __default_attr="928404" __jive_macro_name="message" class="jive_macro jive_macro_message" data-orig-content="Struggle with 'if' statement in email script" data-renderedposition="52_709.421875_271_16" href="https://www.servicenow.com/community?id=community_question&amp;amp;sys_id=07f0dfa9dbdcdbc01dcaf3231f96190e"&gt;Struggle with 'if' statement in email script&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to get to get certain text to show only if State = Resolved. &amp;nbsp; I have tried many different combinations of if (state == 'Resolved') even putting the values into variables and then comparing the variables. &amp;nbsp; I know the if statement is at lease making an evaluation, because it does print the horizontal line in the else section. &amp;nbsp; 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.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have found something that works, please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Adam Robbins&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2017 20:58:41 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501209#M72988</guid>
      <dc:creator>Adam Robbins1</dc:creator>
      <dc:date>2017-09-20T20:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501210#M72989</link>
      <description>&lt;P&gt;On the state field is the value of resolved state 'resolved'?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Think out of the box they assign numbers to the state and only the label has text&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2017 21:06:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501210#M72989</guid>
      <dc:creator>snowtech1</dc:creator>
      <dc:date>2017-09-20T21:06:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501211#M72990</link>
      <description>&lt;P&gt;Can you post your email script. It should be current.state=='Resolved' I think&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2017 21:06:14 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501211#M72990</guid>
      <dc:creator>SanjivMeher</dc:creator>
      <dc:date>2017-09-20T21:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501212#M72991</link>
      <description>&lt;P&gt;Here is what I currently have:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;(function runMailScript(current, template, email, email_action, event) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; var strState = '${state}';&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; var strResolved = 'Resolved';&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; template.print('&amp;lt;hr&amp;gt;&amp;lt;p&amp;gt;&amp;lt;font size="4" color="#999999" face="helvetica"&amp;gt;&amp;lt;strong&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; template.print(gs.getMessage('State') + ': ' + '&amp;lt;/strong&amp;gt;${state}&amp;lt;strong&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; template.print('1' + strState + '111' + strResolved + '1&amp;lt;br&amp;gt;' );&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; template.print(gs.getMessage('Comments') + ':');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; template.print('&amp;lt;/strong&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/p&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; template.print('&amp;lt;p&amp;gt;&amp;lt;font size="3" color="#808080" face="helvetica"&amp;gt;' + current.comments_and_work_notes.getJournalEntry(1) + '&amp;lt;/font&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; if (strState === strResolved){&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;template.print('&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;&amp;lt;font size="4" color="#999999" face="helvetica"&amp;gt;&amp;lt;strong&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;template.print(gs.getMessage('Close Code &amp;amp; Notes') + ': ' + '&amp;lt;/strong&amp;gt;${close_code}&amp;lt;strong&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;template.print('&amp;lt;/strong&amp;gt;&amp;lt;/font&amp;gt;&amp;lt;/p&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;template.print('&amp;lt;p&amp;gt;&amp;lt;font size="3" color="#808080" face="helvetica"&amp;gt;' + gs.getMessage('${close_notes}') + '&amp;lt;/font&amp;gt;&amp;lt;hr&amp;gt;&amp;lt;/p&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; else {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;template.print('&amp;lt;hr&amp;gt;&amp;lt;/p&amp;gt;');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt; }&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;})(current, template, email, email_action, event);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Here is the result:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="find_real_file.png"&gt;&lt;img src="https://www.servicenow.com/community/image/serverpage/image-id/27719iA436B4671F918E37/image-size/large?v=v2&amp;amp;px=999" role="button" title="find_real_file.png" alt="find_real_file.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2017 21:13:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501212#M72991</guid>
      <dc:creator>Adam Robbins1</dc:creator>
      <dc:date>2017-09-20T21:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501213#M72992</link>
      <description>&lt;P&gt;Hello Adam,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Please try these recommendations:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;.trim() on the strings&lt;/LI&gt;&lt;LI&gt;.valueOf() to convert the string to a primitive&lt;/LI&gt;&lt;LI&gt;use '===' instead of '==' ('===' will not do type conversion)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2017 21:14:04 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501213#M72992</guid>
      <dc:creator>Patrick Fedigan</dc:creator>
      <dc:date>2017-09-20T21:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501214#M72993</link>
      <description>&lt;P&gt;Please try current.state.getDisplayValue() ?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2017 21:17:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501214#M72993</guid>
      <dc:creator>snowtech1</dc:creator>
      <dc:date>2017-09-20T21:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use an If statement in email scripts to evaluate Incident State</title>
      <link>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501215#M72994</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I adjusted my variable as follows and it worked &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" data-renderedposition="50_300.578125_16_16" src="https://www.servicenow.com/8.0.4.21bdc7e/images/emoticons/happy.png"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var strState = current.state.getDisplayValue();&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2017 21:21:22 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/how-to-use-an-if-statement-in-email-scripts-to-evaluate-incident/m-p/501215#M72994</guid>
      <dc:creator>Adam Robbins1</dc:creator>
      <dc:date>2017-09-20T21:21:22Z</dc:date>
    </item>
  </channel>
</rss>

