Regarding Make fields Mandatory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 02:39 AM
Hi Team,
I need to make contact name and contact number mandatory while clicking Appointment Booking button before book appointment need these two fields should be mandatory, here there is state changing and all only booking appointment. Kindly provide better approach.
Thanks and Regards
Haritha
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 02:57 AM
Hi @Gariki Haritha ,
Just make a UI Policy which make the fields mandatory based on specific condition.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 02:58 AM
you can make your UI Action "Appointment Booking button" as client callable and use below method to set fields mandatory
g_form.setMandatory('fieldname',true);
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 02:58 AM
on which form this is required? please share screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 03:02 AM - edited 10-03-2023 03:07 AM
Try this code in your UI Action and refer the screenshots for the UI Action configuration.
And make sure that there are UI Poilcy or Client Script which will make the fields mandatory when state is changed. If they are not make them mandatory in the UI Action script itself using g_form.setMandatory('FIELD_NAME', true);
function bookAppointment(){
g_form.setValue("state", "<YOUR_STATE_VALUE>");
gsftSubmit(null, g_form.getFormElement(), 'book_appoinment_ui_action');
}
if (typeof window == 'undefined')
updateAndRedirect();
function updateAndRedirect() {
current.update();
action.setRedirectURL(current);
}
Please mark my answer helpful and accept as solution if it helped 👍✔️
Anvesh