- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 03:45 AM - edited 09-14-2023 03:47 AM
Hi,
I have a request which is related to the Change Request form, where on form closure, if the close code is unsuccessful then the close notes will auto populate the text - "Explain why this change is not successful?"
I am able to populate the text via UI policy script -
------------------
function onCondition() {
g_form.setValue('close_notes', 'Explain why this change is not successful?;
}
------------------
But the issue is the above mentioned text is considered as fulfilling the close notes "mandatory" field condition, and users can just save the form without adding any additional text.
So is there a way to make the close notes field mandatory, even with the text - "Explain why this change is not successful?" present and populated?
I want the close notes asterix symbol to be in red even with the text populated in the field
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 04:02 AM - edited 09-14-2023 04:10 AM
Hi @Happy S
Instead of putting text in close notes you can set "Field Message"
function onCondition() {
g_form.showFieldMsg('close_notes', 'Explain why this change is not successful?');
}
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:27 AM - edited 09-14-2023 05:34 AM
What is the "When to apply" in UI policy ?
If it is like :
close code is unsuccessful
Then in execute if false script part write :
g_form.hideFieldMsg('close_notes',true);
===========================================================
In case you are using onChange client script
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:25 AM
Too bad it doesn't seems to work as the field message is now no longer visible..

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:27 AM
That's strange, can you share your script?
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:27 AM - edited 09-14-2023 05:34 AM
What is the "When to apply" in UI policy ?
If it is like :
close code is unsuccessful
Then in execute if false script part write :
g_form.hideFieldMsg('close_notes',true);
===========================================================
In case you are using onChange client script
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates