getMessage in Declarative List Action

tkachel
Tera Contributor

Hi all,

 

I have created a UI page to be displayed after clicking a button on a list in custom workspace. Everything is finally working well, but I have run into a minor issue.

 

The List Action (Declarative Action/Action Assignment for Lists) is implemented as Client Script, the UI Page is invoked via g_modal.showFrame(). There, I give the UI page a title. However, I have a requirement where the title needs to be either in English, or Italian, based on the user's session's language. And here's where I am having trouble.

 

Neither getMessage(), nowapi.g_i18n.getMessage(), nor g_lang are supported in List Actions (or Declarative Actions in general, probably). 

 

This is the relevant code in the List Action (you can ignore the Ajax call, that's beside the point):

tkachel_0-1729597192993.png

 

I have implemented a work around at the moment - the "title" key/value pair is commented out, and I am simply adding a heading directly in the UI Page HTML code, like this:

tkachel_1-1729597307250.png


Unfortunately, this gives a not-so-great result in the actual UI Page as opposed to the intended OOTB usage, where the position of the title is a bit out of place...

Here, for comparison, is first the "OOTB" version, then my workaround:

tkachel_3-1729597504485.png 

VS.

tkachel_5-1729597584672.png

 

I have also tried modifying the content of that particular heading element with javascript in the UI Page HTML, but it didn't work...

tkachel_6-1729597730108.png

element id obtained from browser ^

 

<g:evaluate var="jvar_title" expression="gs.getMessage('[sensitive data]')"/>

<script>
   document.getElementById("modalHeading-now_modal_6u9khyfair21-193").innerHTML = "${jvar_title}"
</script>

 

my code in the UI Page HTML ^

 

Personally, I guess I can live with it, and hopefully, the client will also be able to, but it seems a bit silly that there is no support for translated messages in Declarative Actions...?

 

If anyone knows how to do this, that would be a huge help.

 

Thanks!

 

P.S.: The instance runs on Washington DC version of ServiceNow.

0 REPLIES 0