<?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 Re: Second Parameter of getMessage() on Client Side in ITSM forum</title>
    <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837848#M409627</link>
    <description>&lt;P&gt;Hi Kiley,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I checked the source code to understand how the function works.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I hope this answers your question.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sergiu&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 01 Jul 2015 07:36:23 GMT</pubDate>
    <dc:creator>sergiu_panaite</dc:creator>
    <dc:date>2015-07-01T07:36:23Z</dc:date>
    <item>
      <title>Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837845#M409624</link>
      <description>&lt;P&gt;I was recently inspired by Chuck Tomasi's post on &lt;A title="gs.getMessage() - The Second Parameter" __default_attr="2197" __jive_macro_name="blogpost" class="jive_macro jive_macro_blogpost" data-orig-content="gs.getMessage() - The Second Parameter" href="https://www.servicenow.com/community?id=community_blog&amp;amp;sys_id=aa1e626ddbd0dbc01dcaf3231f961921"&gt;gs.getMessage() - The Second Parameter&lt;/A&gt;, but when I tried to add a second parameter to the client-side getMessage() function, it didn't seem to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Does anyone know if the &lt;A title="ki.servicenow.com/index.php?title=Client_Scripts#Client_Script_Form" href="http://wiki.servicenow.com/index.php?title=Client_Scripts#Client_Script_Form"&gt;client-side getMessage()&lt;/A&gt; function does not accept a second parameter like the &lt;A title="ki.servicenow.com/index.php?title=GlideSystem#getMessage.28String.2C_Object.29" href="http://wiki.servicenow.com/index.php?title=GlideSystem#getMessage.28String.2C_Object.29"&gt;server-side gs.getMessage()&lt;/A&gt; does?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(If it matters, we're currently on Eureka Patch 7.)&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2015 21:58:53 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837845#M409624</guid>
      <dc:creator>Mike McCall</dc:creator>
      <dc:date>2015-06-29T21:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837846#M409625</link>
      <description>&lt;P&gt;Hello Michael,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;getMessage(String) on client side uses only one parameter vs gs.getMessage(String, Object) that can use a second parameter.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sergiu&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jun 2015 09:50:11 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837846#M409625</guid>
      <dc:creator>sergiu_panaite</dc:creator>
      <dc:date>2015-06-30T09:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837847#M409626</link>
      <description>&lt;P&gt;Sergiu could you please explain how you came to that conclusion? I am also curious by Michael's question and the reasoning behind why that is the case.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Jun 2015 20:05:45 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837847#M409626</guid>
      <dc:creator>kiley</dc:creator>
      <dc:date>2015-06-30T20:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837848#M409627</link>
      <description>&lt;P&gt;Hi Kiley,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I checked the source code to understand how the function works.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I hope this answers your question.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sergiu&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 01 Jul 2015 07:36:23 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837848#M409627</guid>
      <dc:creator>sergiu_panaite</dc:creator>
      <dc:date>2015-07-01T07:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837849#M409628</link>
      <description>&lt;P&gt;Ah ha, straight from the source! Thanks, Sergiu!&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Kiley's second question is a good one, too: is there a particular reason (or reasons) behind limiting the client-side function in this way?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 02 Jul 2015 21:26:55 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837849#M409628</guid>
      <dc:creator>Mike McCall</dc:creator>
      <dc:date>2015-07-02T21:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837850#M409629</link>
      <description>&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;To be honest, I don't know the exact reason behind limiting the client-side function in this way. But, if I think how ServiceNow platform works, everything is a record in a database, so as soon as you need that object from the database you need to do a server-side call, for which we know the solution: gs.getMessage(String, Object). On the other hand, what would be the advantage of multiple arguments to client-side function without doing a server-call? Can't think of many, at least not for this type of function.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sergiu &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 05 Jul 2015 06:47:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837850#M409629</guid>
      <dc:creator>sergiu_panaite</dc:creator>
      <dc:date>2015-07-05T06:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837851#M409630</link>
      <description>&lt;P&gt;I was imagining a reusable message for date range fields. In my Messages, I'd have a record with a Key value of 'Date range - before' and Message value of "{0} must be before {1}."&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Then, in my Client Scripts, I could do something like this:&lt;/P&gt;&lt;BR /&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14362860886015676" jivemacro_uid="_14362860886015676" modifiedtitle="true"&gt;
&lt;P&gt;var msgArray = [];&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;msgArray.push(g_form.getLabelOf('start_date'));&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;msgArray.push(g_form.getLabelOf('end_date'));&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;
&lt;P&gt;alert(getMessage('Date range - before', msgArray)); //...except the second parameter isn't accepted&lt;/P&gt;&lt;BR /&gt;

&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Jul 2015 16:21:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837851#M409630</guid>
      <dc:creator>Mike McCall</dc:creator>
      <dc:date>2015-07-07T16:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837852#M409631</link>
      <description>&lt;P&gt;I agree. &amp;nbsp; There could be numerous use cases for the same functionality client-side.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Sep 2016 04:50:12 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837852#M409631</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2016-09-21T04:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837853#M409632</link>
      <description>&lt;P&gt;Even this is a quite old post: While playing around I stumbled across the &lt;STRONG&gt;GwtMessage()&lt;/STRONG&gt; function. With that function I was able to retrieve my localized message and also replacing the parameters:&lt;/P&gt;
&lt;P&gt;Message Key = {0} must be after {1}&lt;/P&gt;
&lt;P&gt;Message = {0} must be after {1}&lt;/P&gt;
&lt;P&gt;Call in Client Script:&lt;/P&gt;
&lt;P&gt;g_form.showFieldMsg('end_date', &lt;STRONG&gt;new GwtMessage().getMessage("{0} must be after {1}", g_form.getLabelOf("end_date"), g_form.getLabelOf("start_date"))&lt;/STRONG&gt;,'error');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to &lt;A href="https://community.servicenow.com/community?id=community_question&amp;amp;sys_id=e2715f2ddbdcdbc01dcaf3231f961978" rel="nofollow"&gt;this&lt;/A&gt; the function seems not to be documented and should not be used. But even in Madrid it's still used in a couple of ootb code.&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2019 13:01:34 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837853#M409632</guid>
      <dc:creator>gk13</dc:creator>
      <dc:date>2019-08-21T13:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837854#M409633</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;There is a way to&amp;nbsp;pass variables&amp;nbsp;to&amp;nbsp;placeholders in the message within getMessage.&lt;/P&gt;
&lt;P&gt;Use the&amp;nbsp;withValues function on object returned by getMessage.&lt;/P&gt;
&lt;P&gt;Please check the below code.&lt;/P&gt;
&lt;P&gt;// Client script example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; function onLoad() {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get preloaded message&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var myMsg = getMessage("Logout"); // Logout&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get preloaded messsage and format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var myMsg = getMessage("The {0} says {1}!");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myMsg = myMsg.withValues(['cow', 'moo']); // The cow says moo!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get message async&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getMessage("Hello World", function(msg) { g_form.addInfoMessage(msg); } ); // Hello World&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // get message async and format&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getMessage("Good Morning, {0}!", function(msg) { g_form.addInfoMessage(msg.withValues([g_user.getFullName()])); } ); // Good Morning, Fred Luddy!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Suraj&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 13:57:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837854#M409633</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2020-11-09T13:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837855#M409634</link>
      <description>&lt;P&gt;Ooh, interesting! I'll have to try this out (and swap it in for&amp;nbsp;"Correct Answer" if it works).&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Out of curiosity, were you referencing any available documentation to discover this, or did you have to do your own sleuthing/trial-and-error?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The updated server-side documentation is here: &lt;A href="https://developer.servicenow.com/dev.do#!/reference/api/paris/server_legacy/c_GlideSystemAPI#r_GS-getMessage_S_O" target="_blank"&gt;legacy GlideSystem on Paris&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;I&amp;nbsp;&lt;EM&gt;believe&lt;/EM&gt; this is the [official] updated client-side documentation: &lt;A href="https://developer.servicenow.com/dev.do#!/reference/api/paris/client/c_i18NV3API#r_i18n-getMessage_S_F" target="_blank"&gt;i18NV3&amp;nbsp;on Paris&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 09 Nov 2020 14:33:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837855#M409634</guid>
      <dc:creator>Mike McCall</dc:creator>
      <dc:date>2020-11-09T14:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837856#M409635</link>
      <description>&lt;P&gt;Got this from servicenow internal team. I don't know why service now don't update the documentation.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 15:42:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837856#M409635</guid>
      <dc:creator>Community Alums</dc:creator>
      <dc:date>2020-11-09T15:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837857#M409636</link>
      <description>&lt;P&gt;Hi, I have encountered a problem using the withValues function, I get the following error: "getMessage(...).withValues is not a function". &lt;BR /&gt;Do you know what can be the reason for this error?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jun 2021 12:06:17 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/837857#M409636</guid>
      <dc:creator>eden_shavit</dc:creator>
      <dc:date>2021-06-08T12:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/3236828#M539063</link>
      <description>&lt;P&gt;getMessage(string) has only one parameter. But there is a way to pass parameters to the string.&lt;BR /&gt;For example:&lt;BR /&gt;getMessage("Creating new version number {0} and updating in {1}").withValues([variable1, variable2]);&lt;BR /&gt;withValues function can be called on getMessage to pass the parameters.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 09:35:40 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/3236828#M539063</guid>
      <dc:creator>karthik ande</dc:creator>
      <dc:date>2025-04-14T09:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/3238252#M539146</link>
      <description>&lt;P&gt;What is this "withValues" method?&amp;nbsp; It's not a base JavaScript method (that I've found) and does not seem to be documented anywhere by ServiceNow, which brings up the idea of how safe is it to use?&lt;BR /&gt;&lt;BR /&gt;It is a nice way to do the string replacements, but we could just use the "replaceAll" method and feel safe about it.&amp;nbsp; Like:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var message = getMessage("Creating new version number {0} and updating in {1}");
message = message.replaceAll("{0}", variable1);
message = message.replaceAll("{1}", variable2);&lt;/LI-CODE&gt;&lt;P&gt;Not as pretty, but safer?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Apr 2025 12:21:56 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/3238252#M539146</guid>
      <dc:creator>Jim Coyne</dc:creator>
      <dc:date>2025-04-15T12:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Second Parameter of getMessage() on Client Side</title>
      <link>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/3340171#M544889</link>
      <description>&lt;P&gt;I'll leave the current "correct answer" because of semantics: it looks like my original question was whether you could include a parameter or not.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I do like this replaceAll approach! (If I had asked the better question--how do I accomplish the string replacement?--I'd probably mark this as the [safest] solution. &lt;span class="lia-unicode-emoji" title=":trophy:"&gt;🏆&lt;/span&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jul 2025 11:01:00 GMT</pubDate>
      <guid>https://www.servicenow.com/community/itsm-forum/second-parameter-of-getmessage-on-client-side/m-p/3340171#M544889</guid>
      <dc:creator>Mike McCall</dc:creator>
      <dc:date>2025-07-31T11:01:00Z</dc:date>
    </item>
  </channel>
</rss>

