- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2017 02:32 AM
Hi
I am trying to create a new system ui message with dynamic argument which needs to be translated
Here I am sharing how it's configured
alert(getMessage('Additional company'+i+'details' must be entered'));
and have created entry in ui messages table - with key 'Additional company'+i+'details' must be entered' in English and French values. But alert is not getting values from message table.
Please help.
Thanks,
Kiran
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2017 02:56 AM
Hi,
Here is how dynamic variables can be passed to messages
Single Parameter passing, Message sample "Incident {0} is created"
var msg = gs.getMessage('Incident {0} is created', current.number); // This is how you replace variable
Multiple parameter passing, Message sample "Incident {0} is updated to State: {1}"
var arr = [];
arr.push(current.number);
arr.push(current.state);
var msg = gs.getMessage('Incident {0} is updated to State: {1}', arr);
In your case. The message should be, "Additional company {0} details must be entered" and you should replace this in your code
gs.getMessage('Additional company {0} details must be entered', i );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2017 02:43 AM
Hi Kiran,
If you want to concatenate your message and put in some variables, you would need to call getMessage() for each part of the message:
(I assume "i" variable is a string - if not, it needs to be converted into a string first)
alert(getMessage('Additional company') + i + getMessage('details must be entered'));
And create a separate message translation records for each part with a key between the quotation marks above.
Hope this helps.
Andras
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2017 03:29 AM
Thanks Andras,
Actual message is lengthier and using "i" multiple places in that message. So i am trying alternate way.
But this is really helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018 02:47 AM
You can achieve what you want by making use of javascript replace function.
In this way you will be able to use the same message/translation both at client and server side scripts.
Example:
var msg = getMessage('Incident {0} is created').replace('{0}', current.number);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2017 02:56 AM
Hi,
Here is how dynamic variables can be passed to messages
Single Parameter passing, Message sample "Incident {0} is created"
var msg = gs.getMessage('Incident {0} is created', current.number); // This is how you replace variable
Multiple parameter passing, Message sample "Incident {0} is updated to State: {1}"
var arr = [];
arr.push(current.number);
arr.push(current.state);
var msg = gs.getMessage('Incident {0} is updated to State: {1}', arr);
In your case. The message should be, "Additional company {0} details must be entered" and you should replace this in your code
gs.getMessage('Additional company {0} details must be entered', i );