How can I make Category Field mandatory on Security Incident Response Form - Only for New Records

WazzaJC
Tera Expert

How can I make the 'Category' Field mandatory on a Security Incident Response Form - Only for New Records

 

Dear ServiceNow Community colleagues, please may I request your help/advice on how to achieve this.

 

I need to ensure the 'Category' field is mandatory on the Security Incident Response Form - but only for New Records.

 

How can I achieve this using a Client Script and what is the Client Script code to use, assuming this is an onLoad Client Script?

 

I am trying this myself, however it seems to be applying the mandatory field setting (to the Category field) even for existing Security Incident Response records.

 

I want to ensure the field is mandatory only when a new Security Incident Response record is raised.

 

Please see attached screenshot of the Security Incident Response form, showing the 'Category' field that I want to make mandatory - only for new Records.

 

Many thanks for any guidance/advice.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@WazzaJC 

no scripting required.

You can achieve this using UI policy

UI Policy Condition: Created [IS EMPTY] (This condition will only satisfy for new record)

UI Policy Action: make field mandatory

AnkurBawiskar_0-1747303470750.png

New Record:

AnkurBawiskar_1-1747303515024.png

 

Existing Record:

AnkurBawiskar_2-1747303556847.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Arun_Manoj
Mega Sage

Hi @WazzaJC 

 

Create a Client Script:

  • Table: sn_si_incident (or your specific Security Incident table)

  • Type: onLoad

  • UI Type: All   

function onLoad() {
if (g_form.isNewRecord()) {
g_form.setMandatory('category', true);
}
}

shantanu_patel8
Mega Guru

Hi @WazzaJC ,

 

The solution suggested by @Arun_Manoj is good if you are only trying to make the category as mandatory from the client side expecting that the security incident can only be created by user directly from native UI.

 

Other ways you can also use:

1. UI Policy with "category" as mandatory.

2. Data policy with "category" as mandatory, this will restrict creation of security incident even if record gets created from API.

 

Please mark the answer helpful and correct if it resolves the issue. Happy scripting 🙂

 

-Shantanu

Thanks very much Arun, I appreciate your help with this guidance, much appreciated 🙂

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @WazzaJC 

 

Why not you try to make it mandatory when SIR in new state only.

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

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