Mandatory Field on HR Case Creation

artur3
Mega Guru

Hello, I have a requirement to make Opened For field as mandatory on HR Case Creation step. I can't find a place to do that. UI Policy is not working for this place. I can't find it anywhere on Case Configuration that is related to making fields mandatory. Would appreciate a support.

case creation.jpg

6 REPLIES 6

Ahana 01
Tera Expert

Sure, you can make the 'Opened For' field mandatory on HR Case Creation step by using a Client Script. Here are the steps:

1. Navigate to System Definition > Client Scripts in ServiceNow.
2. Click on New to create a new client script.
3. Fill in the fields:
- Name: Give a name to your client script.
- Table: Select 'HR Case' from the dropdown.
- Type: Select 'onLoad'.
- Active: Make sure it's checked.
- Script: Add the following script:

function onLoad() {
var openedForField = g_form.getControl('opened_for');
if (openedForField) {
openedForField.setAttribute('mandatory', true);
}
}

4. Click on Submit to save the client script.

This script will make the 'Opened For' field mandatory when the HR Case form is loaded. If the field is not filled, the form cannot be submitted.

AndersBGS
Tera Patron
Tera Patron

Hi @artur3 ,

 

Go to Case Creation Configuration:

AndersBGS_0-1705579236035.png

 

 

Then under Case creation you can see the field "left task fields":

AndersBGS_1-1705579236049.png

Open the form design and make it mandatory

AndersBGS_2-1705579293068.png

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/

Jaspal Singh
Mega Patron
Mega Patron

Hi,

I believe you might need to make the field mandatory at the dictonary level for Opened for. If you wish to add/remove field you can navigate to HR Administration >> HR Case Configuration. However, mandatory can only be at dictionary level for the field

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @artur3 

 

If you want to make in conditions the use UI policy or even without condition too. or another way is make the filed mandatory at table level itself as shown by @AndersBGS 

*************************************************************************************************************
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]

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