How to Restrict Closure Without Work Notes

Shailja Dosar
Tera Contributor

 

Hi Team,

I am writing a business rule to prevent incidents from being closed unless at least one work note is added. Although I have implemented this, it is not very user-friendly, so I am looking for some refinement or alternative solutions.

In my current code, I display an error message: "You cannot mark the state as closed until you add at least one work note."

However, the code does not revert the state to its previous status, like "In progress." While it shows an "Invalid update" message, it does not clearly indicate that the incident has not been updated and remains in its previous state. How can I achieve this?

(attached is my BR code snip and Incident form Error snip)

Thank you.

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

HI @Shailja Dosar , 

 

You don't have to glide sys_journal table for this, you can have below logic

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(current.work_notes.getJournalEntry(1).length==0){ //check if atleast one work note is addded
		gs.addErrorMessage("You cannot mark the state is closed until update atleast one worknotes!!!")
		current.setAbortAction(true); //Abort the action
	}

})(current, previous);

 

Business Rule :

HemanthM1_0-1735840502887.png

 

HemanthM1_1-1735840531008.png

 

Result: 

Ignore messages in blue, state says closed but you need to reload the state value is not updated in the database!

HemanthM1_2-1735840679721.png

 

 

If you really want to abort the state change, apply the same logic in the 'Close Incident' UI action so that it will check the work notes first before setting the state to closed and throw errors.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

2 REPLIES 2

Hemanth M1
Giga Sage
Giga Sage

HI @Shailja Dosar , 

 

You don't have to glide sys_journal table for this, you can have below logic

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	if(current.work_notes.getJournalEntry(1).length==0){ //check if atleast one work note is addded
		gs.addErrorMessage("You cannot mark the state is closed until update atleast one worknotes!!!")
		current.setAbortAction(true); //Abort the action
	}

})(current, previous);

 

Business Rule :

HemanthM1_0-1735840502887.png

 

HemanthM1_1-1735840531008.png

 

Result: 

Ignore messages in blue, state says closed but you need to reload the state value is not updated in the database!

HemanthM1_2-1735840679721.png

 

 

If you really want to abort the state change, apply the same logic in the 'Close Incident' UI action so that it will check the work notes first before setting the state to closed and throw errors.

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hi @Hemanth M1 ,

 

Thanks for your solution it helps.