Make Change Request close notes field mandatory with script populated text present?

Happy S
Tera Expert

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?

 

 

HappyJ_1-1694688406532.png

 

 I want the close notes asterix symbol to be in red even with the text populated in the field

HappyJ_0-1694688391106.png

 

 

Thank you

2 ACCEPTED SOLUTIONS

Vishal Birajdar
Giga Sage

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?');
}

 

VishalBirajdar7_0-1694689822499.png

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

What is the "When to apply" in UI policy ?

If it is like :

close code is unsuccessful 

VishalBirajdar7_1-1694694423187.png

 

 

 

Then in execute if false script part write :

 

g_form.hideFieldMsg('close_notes',true);

VishalBirajdar7_0-1694694353613.png

 

===========================================================

 

In case you are using onChange client script

 

VishalBirajdar7_0-1694694855822.png

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

View solution in original post

7 REPLIES 7

Too bad it doesn't seems to work as the field message is now no longer visible..

 

HappyJ_0-1694694304344.png

 

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.

What is the "When to apply" in UI policy ?

If it is like :

close code is unsuccessful 

VishalBirajdar7_1-1694694423187.png

 

 

 

Then in execute if false script part write :

 

g_form.hideFieldMsg('close_notes',true);

VishalBirajdar7_0-1694694353613.png

 

===========================================================

 

In case you are using onChange client script

 

VishalBirajdar7_0-1694694855822.png

 

 

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates