Mandate Additional Comments

Community Alums
Not applicable

Hi,

Iam trying to make Additional Comments mandatory when incident state is cancelled. For this i created UI Policy with condition State is Cancelled and UI action where additional comments are mandatory true.

 

But it is allowing incident form to save and then additional comments are becoming mandatory, how to make it mandatory before saving the form using this UI Policy

5 REPLIES 5

Anurag Tripathi
Mega Patron
Mega Patron

You can update the UI action script to check if the comment is blank, if it is blank them make it mandatory and throw error, only when comment is not blank you proceed with the rest of the code in the ui aciton.

-Anurag

sourav1999
Mega Guru

For a good and optimistic result, please visit this website. It uses a Chat Generative Pre-Trained Transformer ( GPT ) technology for solving ServiceNow-related issues.

Link - https://nowgpt.ai/

Brad Bowman
Kilo Patron
Kilo Patron

An alternate approach is an onChange Client Script when the State changes:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
	if (isLoading || newValue === '') {
		return;
	}
	if (newValue == 8 ) { //Cancelled
		g_form.setMandatory('comments', true);
	} else {
		g_form.setMandatory('comments', false);
	}
}

 

priyasunku
Kilo Sage

Hi @Community Alums 

 

You can write on change client script on state field as you want comments to be mandatory when state changes.

 

If my answer solved your issue, please mark my answer as Correct & 👍Helpful