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

Prince Arora
Tera Sage
Tera Sage

@Lydon 

 

1) Please make your UI policy active which should be run on the onLoad.

2) Change the code of UI action as below (No need of gsft_submit)

 

function moveToImplement(){

g_form.setValue("state","-1");

g_form.save();

}

Also remove, current.setMandatory as this is not a valid function

 

Once state has been updated, Ui policy will automatically updated the field as mandatory

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

 

@Danish Bhairag2 @Prince Arora 

 

I have attempted that solution and scraped it because the change is now by passing the scheduled state and jumping right to the implement state. 

@Lydon 

 

It should work! why it is bypassing

Could you please share your script now

Lydon_0-1700850375960.png

 

@Lydon 

 

Please comment the another code except first two line and execute the flow and let me know what will happen