- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2015 10:50 AM
I'm struggling to understand exactly what the use of the "Messages" field is in Client Scripts: Client Scripts - ServiceNow Wiki
If I have a record (or records) in the Messages [sys_ui_message] table with a Key value of 'Start date must be after end date', then I know my Client Script will have the following:
getMessage('Start date must be after end date');
If I want to make use of the Messages field on my Client Script, do I just add the text 'Start date must be after end date' in the field?
Assuming that I do add the text directly in the Messages field (and don't then make any change to the line in my actual script), what is the benefit? Is the system loading the message once as the form loads, then storing it in a locally-accessible location for the duration of the form's usage? (Re: Support for HTML 5 placeholder attribute)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2015 01:00 PM
You are correct! The message will be stored locally on the client if both, you add it to the script or if you add it to the messages field.
The advantage of the message field is it will prevent another round trip to the server if the system detects the user's preferences consists of a different language, thus displaying the message in accordance to that user's language preference. But to prevent this round trip, you also need a matching record in the the sys_ui_message table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2015 01:00 PM
You are correct! The message will be stored locally on the client if both, you add it to the script or if you add it to the messages field.
The advantage of the message field is it will prevent another round trip to the server if the system detects the user's preferences consists of a different language, thus displaying the message in accordance to that user's language preference. But to prevent this round trip, you also need a matching record in the the sys_ui_message table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-26-2015 01:31 PM
So, if I plan to call...
getMessage('Start date must be after end date')
...twice in a single script without adding anything to the Messages field of that Client Script record*, will that result in two trips to the server?
If I do the same and add 'Start date must be after end date' as a line in the Messages field of that Client Script record*, I'll be improving performance?
What if I only plan to use getMessage once in a single script?* Is there still a benefit to utilizing the Messages field?
(Do your answers depend on whether or not I have multiple languages in my system?)
*You can assume that I do have at least one [sys_ui_message] record with a Key value of 'Start date must be after end date' in all of my scenarios.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 09:57 AM
For the heck of it, here's a related post with the same outcome: Client script - Message field