Make Actual end date mandatory when I select the implement button

Lydon
Mega Expert

I have a requirement to make the actual end date field on mandatory when change is in the implement state. This will normally be a UI action which I have done but the problem is when I select the implement button, changes move to the implement state and the actual end date becomes mandatory as expected but does not stay in implement state when refreshed.

 

See UI Policy

Lydon_0-1700845015900.pngLydon_1-1700845041996.png

Cannot seem to get this to work as intended, so I marked the UI Policy and inactive and modified the UI Action for implement and added a line of code current.setMandatory("work_end",true);

Lydon_2-1700845282406.png

This seem to do the trick, but business is saying they want mandatory field to show as mandatory prior to trying to move to Review state.

 

Currently does not show as mandatory unless the attempt to move to the review state, that's when it lets them know they field is a mandatory field. 

 

How can I make this field mandatory as soon as the implement button is selected, and it stays on the implement state even if I refresh the page? 

 

 

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

This is an easy scenario to replicate with the information you have provided, and test.  What's happening is the UI Action first changes the State to 'Implement'.  With a UI Policy or Data Policy in place, this field immediately becomes mandatory, so the form cannot be submitted or saved without populating the Actual end date, therefore the update is aborted, so the record is still in the Authorize state when the form is refreshed.  For this reason, the UI Policy needs to be inactivated, or better yet deleted.  Put the 'Implement' UI Action back to out of box, and create a simple Client Script on the change_request table:

 

function onLoad() {
	if (g_form.getValue('state') == -1 || g_form.getValue('state') == 0 || g_form.getValue('state') == 3) { //Implement, Review, Closed
		g_form.setMandatory('work_end', true);
	}
}

 

 

View solution in original post

15 REPLIES 15

Kavita_Bhojane
Tera Guru

Hi @Lydon,

 

Make the actual end date field mandatory when change is in the scheduled, implement, review and closed state. You can go with UI policy.

 

Please mark my answer helpful and accept the solution if you find it useful. 

 

Thanks,

Kavita Bhojane

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Lydon ,

 

Is your UI action client checked or unchecked? as i could see u have used g_form & current it will not work in same UI action.

 

Please try this Keep ur UI policy active for making the field as mandatory when state is in implement.

 

in ur UI action after g_form.setValue use this command:

 

 

g_form.save();

 

This should do the trick. Also remove current.setMandatory line not required.

 

Thanks,

Danish

 

 

UI action client is checked 

Dr Atul G- LNG
Tera Patron
Tera Patron

But the actual date must be auto populate by the system not by user. Please chk the OOTB code this. @Lydon 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************