<?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 Input Parameters on Notification email script in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662295#M1032733</link>
    <description>&lt;P&gt;Can I use input parameter in an email script?&lt;/P&gt;&lt;P&gt;I have this code on my notification's body&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;HTTP Status: ${u_notes}

${mail_script:ErrorReportNotificationScript}

&amp;lt;mail_script&amp;gt;errorReport(${u_notes});&amp;lt;/mail_script&amp;gt;  

&lt;/LI-CODE&gt;&lt;P&gt;And this on my Email Script&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {

	function errorReport(status){
		if (status &amp;gt;= 400 &amp;amp;&amp;amp; status &amp;lt; 499) {
			template.print("&amp;lt;p&amp;gt;Client Error!&amp;lt;/p&amp;gt;");	
		} else if (status &amp;gt;= 500 &amp;amp;&amp;amp; status&amp;lt; 599) {
			template.print("&amp;lt;p&amp;gt;Server Error!&amp;lt;/p&amp;gt;");	
		} else {
			template.print("&amp;lt;p&amp;gt;Error!&amp;lt;/p&amp;gt;");	
		}
	}
	

})(current, template, email, email_action, event);&lt;/LI-CODE&gt;&lt;P&gt;I know that the code is not working but i put the code here just for an simple representation&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2023 11:35:08 GMT</pubDate>
    <dc:creator>joao_graca</dc:creator>
    <dc:date>2023-09-05T11:35:08Z</dc:date>
    <item>
      <title>Input Parameters on Notification email script</title>
      <link>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662295#M1032733</link>
      <description>&lt;P&gt;Can I use input parameter in an email script?&lt;/P&gt;&lt;P&gt;I have this code on my notification's body&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;HTTP Status: ${u_notes}

${mail_script:ErrorReportNotificationScript}

&amp;lt;mail_script&amp;gt;errorReport(${u_notes});&amp;lt;/mail_script&amp;gt;  

&lt;/LI-CODE&gt;&lt;P&gt;And this on my Email Script&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {

	function errorReport(status){
		if (status &amp;gt;= 400 &amp;amp;&amp;amp; status &amp;lt; 499) {
			template.print("&amp;lt;p&amp;gt;Client Error!&amp;lt;/p&amp;gt;");	
		} else if (status &amp;gt;= 500 &amp;amp;&amp;amp; status&amp;lt; 599) {
			template.print("&amp;lt;p&amp;gt;Server Error!&amp;lt;/p&amp;gt;");	
		} else {
			template.print("&amp;lt;p&amp;gt;Error!&amp;lt;/p&amp;gt;");	
		}
	}
	

})(current, template, email, email_action, event);&lt;/LI-CODE&gt;&lt;P&gt;I know that the code is not working but i put the code here just for an simple representation&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 11:35:08 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662295#M1032733</guid>
      <dc:creator>joao_graca</dc:creator>
      <dc:date>2023-09-05T11:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Input Parameters on Notification email script</title>
      <link>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662356#M1032754</link>
      <description>&lt;P&gt;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/561377"&gt;@joao_graca&lt;/a&gt;&amp;nbsp;Unfortunately, you can't pass any parameters directly in email script from a notification body. However, you can still pass parameters through event parameters (Event param 1 or param 2). You can set these param values while triggering the event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Source:&amp;nbsp;&lt;A href="https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/script/server-scripting/concept/c_ScriptingForEmailNotifications.html" target="_blank"&gt;https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/script/server-scripting/concept/c_ScriptingForEmailNotifications.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.servicenow.com/en-US/bundle/vancouver-build-workflows/page/administer/platform-events/concept/events.html" target="_blank"&gt;https://docs.servicenow.com/en-US/bundle/vancouver-build-workflows/page/administer/platform-events/concept/events.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 12:12:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662356#M1032754</guid>
      <dc:creator>Sandeep Rajput</dc:creator>
      <dc:date>2023-09-05T12:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Input Parameters on Notification email script</title>
      <link>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662381#M1032769</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://www.servicenow.com/community/user/viewprofilepage/user-id/561377"&gt;@joao_graca&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;While you cannot directly pass parameters to an email script from a notification body, you can use event parameters to achieve a similar outcome.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Event parameters allow you to pass additional data when triggering an event.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {

    // Retrieve event parameters
    var parm1 = event.parm1;

    // Check if parm1 has a value
    if (parm1) {
        // Now you can use 'parm1' in your email script logic
        if (parm1.indexOf("400") !== -1 || parm1.indexOf("499") !== -1) {
            template.print("&amp;lt;p&amp;gt;Client Error!&amp;lt;/p&amp;gt;");
        } else if (parm1.indexOf("500") !== -1 || parm1.indexOf("599") !== -1) {
            template.print("&amp;lt;p&amp;gt;Server Error!&amp;lt;/p&amp;gt;");
        } else {
            template.print("&amp;lt;p&amp;gt;Error!&amp;lt;/p&amp;gt;");
        }
    } else {
        template.print("&amp;lt;p&amp;gt;No HTTP Status found!&amp;lt;/p&amp;gt;");
    }

})(current, template, email, email_action, event);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Tushar&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2023 12:28:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662381#M1032769</guid>
      <dc:creator>Tushar</dc:creator>
      <dc:date>2023-09-05T12:28:36Z</dc:date>
    </item>
    <item>
      <title>Re: Input Parameters on Notification email script</title>
      <link>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662393#M1032775</link>
      <description>&lt;P&gt;Hello&amp;nbsp;joao_graca,&lt;/P&gt;&lt;P&gt;can you try this...!!&lt;/P&gt;&lt;P&gt;In the mail script you can get value of&amp;nbsp; "u_notes" by using current object. then you can call errorReport function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template, /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action, /* Optional GlideRecord */ event) {&lt;BR /&gt;&lt;BR /&gt;//Get the value of notes&lt;BR /&gt;var status = current.u_notes;&lt;BR /&gt;&lt;BR /&gt;//call the function&lt;BR /&gt;&lt;SPAN&gt;errorReport(status);&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; function errorReport(status){&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; if (status &amp;gt;= 400 &amp;amp;&amp;amp; status &amp;lt; 499) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; template.print("&amp;lt;p&amp;gt;Client Error!&amp;lt;/p&amp;gt;"); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; } else if (status &amp;gt;= 500 &amp;amp;&amp;amp; status&amp;lt; 599) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; template.print("&amp;lt;p&amp;gt;Server Error!&amp;lt;/p&amp;gt;"); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; } else {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; template.print("&amp;lt;p&amp;gt;Error!&amp;lt;/p&amp;gt;"); &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; }&lt;/SPAN&gt;&lt;BR /&gt;})(current, template, email, email_action, event);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notification&amp;nbsp; body :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;HTTP Status: ${u_notes}

${mail_script:ErrorReportNotificationScript}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Sep 2023 12:34:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/input-parameters-on-notification-email-script/m-p/2662393#M1032775</guid>
      <dc:creator>Vishal Birajdar</dc:creator>
      <dc:date>2023-09-05T12:34:17Z</dc:date>
    </item>
  </channel>
</rss>

