- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 05:22 PM
There are workarounds to this, but none of them are exactly what I am looking to accomplish & I more or less want to know if this can be done at this point because I can't seem to figure it out.
- I want a True/False field to control an info message being displayed on the form.
- If the field is set to true, the message should show & if the field is set to false, the message should be removed.
- There should not be a limit to the number of times the message can be shown / removed without reloading the form.
- I want the message to be displayed at the top of the form opposed to below the field.
- The message should be able to have HTML, which shouldn't be an issue for info message but becomes an issue if I go the field message route.
- I do not want to clear all messages being displayed on the form when the value is set to false, rather only remove the message that is being controlled by the true/false field.
I've tried using both an onChange Client Script & a UI policy, but both seem to give me the same result. In the script below, I have a condition on the UI policy I am using set to run when my field is set to true. Additionally Isolate script is set to false.
Execute if true:
function onCondition() {
g_form.addInfoMessage('Please note this info', 'myInfoMessage');
}
Execute if false:
function onCondition() {
$j('#myInfoMessage').remove();
}
This almost works & gets very close to what I am looking for, however it acts very odd & will initially display the message when set to true, will remove the message when set to false, and finally will do nothing when set to true again.
I tried to get creative & thought maybe if I utilize the scratchpad to hold a count, then change the name of the message each time that I may be able to get different results. Sadly this was not the case & the code below does the same thing as the code above, however the alert does count up indicating to me that my script logic at the least appears to be working
Execute if true:
function onCondition() {
if (g_scratchpad.message == null || g_scratchpad.message == ''){
g_scratchpad.message = 1;
} else {
var num = g_scratchpad.message;
g_scratchpad.message = num + 1;
alert(num);
}
var messageName = 'myInfoMessage' + g_scratchpad.message;
g_form.addInfoMessage('Please note this info', messageName);
}
Execute if false:
function onCondition() {
var messageName = '#myInfoMessage' + g_scratchpad.message;
$j(messageName).remove();
}
Additionally with the code described above, I found that the message can be shown -> removed -> re-shown if I set the field to true, then click the X on the info message to remove it, then set the field to false (nothing happens as the info message was already removed with the X), and finally set the field to true again. I suspect this is similar logic to g_form.clearMessages() which I'm trying to avoid using, but none the less I found it interesting.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 10:05 PM
Hello,
Here is the code. Works for me should work for you:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var know=g_form.getValue('knowledge');
g_form.addInfoMessage('Please note this info', 'myInfoMessage');
if(know=='true')
{
$j('#myInfoMessage').show('');
}
else
{
$j('#myInfoMessage').hide('');
}
}
Please mark the answer as correct.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 08:25 PM
If that is the case why not use Fieldmsg instead of info message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 08:44 PM
A field message does work in the way I would like, however it also brings additional complications & isn't as "in your face" of an approach that has been requested by numerous teams for various reasons.
The first complication is that I need hyperlinks in the message. This is possible, but not without somewhat forcing it to.
Additionally there are multiple scripts in the instance that use this methodology where the request has been to have a banner displayed at the top of the form.
For example there is one setup on the incident table that runs if a true/false value is set on the Caller's user record, notifying any analyst that opens the incident immediately to follow a specific process via a link to a knowledge document.
If the analyst changes the caller from a user that has the value set true to a user that has the value set to false the message should be removed. A situation I'm trying to account for is if this happens mistakenly & the caller is then set back to the initial user, I want that info message to be re-displayed.
I'm fully aware there are multiple workarounds to this, but as I mentioned none of them are exactly what I'm looking to accomplish & this just feels like something that shouldn't be that challenging of a thing to do.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 10:05 PM
Hello,
Here is the code. Works for me should work for you:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var know=g_form.getValue('knowledge');
g_form.addInfoMessage('Please note this info', 'myInfoMessage');
if(know=='true')
{
$j('#myInfoMessage').show('');
}
else
{
$j('#myInfoMessage').hide('');
}
}
Please mark the answer as correct.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-11-2022 11:49 PM
Did you get a chance to check?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2022 07:23 AM
This works FLAWLESSLY! Thank you!!