- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 09:08 AM
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
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);
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 10:46 AM - edited ‎11-24-2023 12:21 PM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 09:33 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 09:34 AM - edited ‎11-24-2023 09:36 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 10:14 AM
UI action client is checked
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-24-2023 09:45 AM
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]
****************************************************************************************************************