- 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 03:56 AM - edited 09-14-2023 03:57 AM
Hi @Happy S,
First things first. I would not recommend doing this, but instead use annotations for it.
That being said, if you really need to do this, create a onload client script (or in the UI policy you tried already if you want it only on a certain condition):
function onLoad() {
var notes= g_form.getControl('close_notes');
notes.placeholder = "Explain why this change is not successful?.";
}
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 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:16 AM
Somehow if I toggle between the Close Codes - successful and unsuccessful the message keeps displaying on top of each other..
Anyway to have it display only once?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 05:18 AM - edited 09-14-2023 05:19 AM
Hi @Happy S ,
Add this in front of the showfieldmsg
g_form.hideFieldMsg('close_notes',true);
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.