The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Before buisines rule

krishna_1B
Tera Contributor

Can delete a record in incident table once we set the impact,urgent,priority to 1 
Like can we write a script in Before BR for both creating inc with priority high and after creating it can we delete it using same BR ?

7 REPLIES 7

Nikhil Bajaj9
Tera Sage

Hi @krishna_1B ,

 

No it is not possible with Before business Rule but what is your use case?

 

If my answer helped you, please mark it - Solution accepted. 

 

Regards,

Nikhil Bajaj

Please appreciate my efforts, help and support extended to you by clicking on – “Accept as Solution”; button under my answer. It will motivate me to help others as well.
Regards,
Nikhil Bajaj

Rafael Batistot
Kilo Patron

Hi @krishna_1B 

 

There is a safe approach for you require 

 

Instead of allowing the record to be created and then deleting it, you can stop the record from ever being created in the first place.

 

May you handle using a Before > Insert Business Rule 


Code: 

if (current.operation() == 'insert' && current.impact == 1 && current.urgency == 1 && current.priority == 1) {
gs.addErrorMessage("Incidents with Priority 1 cannot be created.");
current.setAbortAction(true); // stop the insert
}

AndersBGS
Tera Patron
Tera Patron

Hi @krishna_1B ,

 

 what is the context? what is the business requirement? Your question is quite confusing.

 

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/

Bhuvan
Kilo Patron

@krishna_1B 

 

Answer is NO. Before BR are run before a record is inserted to the database. If you create a before BR to update the Impact, Urgency and Priority to 1 but not completing the DB operation and trying to delete the record, it will not be recorded in the database. You should always validate business requirements and whether it would help optimize your processes before scripting. Even if something is possible in scripts, you should always think from best practices perspective and long-term impact & the justification for creating a custom script in the first place.

 

Business Rules are server-side scripts that performs database operations when a record is inserted/updated/deleted/queries. 'When' is a choice field in BR and dictates when it should execute before/after/async/display.

Bhuvan_0-1755995387913.png

You can find more information from below link,

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/zurich/new_to_servicenow/app_store_le...

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/zurich/new_to_servicenow/app_store_le...

 

If this helped to answer your query, please mark it helpful & accept the solution.

 

Thanks,

Bhuvan