i used same script for before and after business rule (insert,update) it works in both BR

samreenayesha
Tera Contributor

Any explanation why? its bit confusing 

1 ACCEPTED SOLUTION

Got you !!

 

Why Your Script Works in Both

  • Before Business Rule: When you create the Problem ticket in a "Before" Business Rule, it ensures that the Problem ticket creation is part of the Incident creation transaction. If the Incident fails to be saved for any reason, the Problem ticket creation will also be rolled back.

  • After Business Rule: When the same script is used in an "After" Business Rule, it creates the Problem ticket only after the Incident is successfully saved. This is useful if you want to ensure that the Incident has been committed before any related records are created.

Choosing Between "Before" and "After"

  • Consistency vs. Dependency: If the creation of the Problem ticket should always happen in tandem with the Incident (e.g., if creating a Problem is a business-critical part of the Incident creation), a "Before" Business Rule is appropriate.
  • Asynchronous Needs: If creating the Problem ticket can be done asynchronously or does not need to block the Incident creation, then an "After" Business Rule is suitable.

Given the script works in both, you'll want to consider the business requirements:

  • Use Before if the Problem creation is tightly coupled with the Incident creation.
  • Use After if you prefer to ensure that the Incident is created first, and then create the Problem ticket without holding up the Incident creation process.
 



Choosing Between "Before" and "After"

  • Consistency vs. Dependency: If the creation of the Problem ticket should always happen in tandem with the Incident (e.g., if creating a Problem is a business-critical part of the Incident creation), a "Before" Business Rule is appropriate.
  • Asynchronous Needs: If creating the Problem ticket can be done asynchronously or does not need to block the Incident creation, then an "After" Business Rule is suitable.

Given the script works in both, you'll want to consider the business requirements:

  • Use Before if the Problem creation is tightly coupled with the Incident creation.
  • Use After if you prefer to ensure that the Incident is created first, and then create the Problem ticket without holding up the Incident creation process.
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ļ”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ļ”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

4 REPLIES 4

WarnerMarkk
Tera Contributor

Can you share a bit more about what your script does? Understanding the logic might help clarify why it works for both Before and After BRs. In some cases, it might be a coincidence, and separate BRs could be beneficial.

Ravi Gaurav
Giga Sage
Giga Sage

Hi @samreenayesha 

Can you share the use case  so that we can comment why It worked as both are different:-

 

  • Before Business Rules: These rules are executed before the database operation (insert, update, delete) is performed. They can be used to validate data, set default values, or cancel the operation if certain conditions are not met.
  • After Business Rules: These rules are executed after the database operation is performed. They can be used to perform additional actions, such as sending notifications, updating related records, or triggering workflows.
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ļ”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ļ”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

samreenayesha
Tera Contributor

if P2 incident got created then problem ticket should also be get created so i wrote the script and it works in both BR ,before and after also got confused 

Got you !!

 

Why Your Script Works in Both

  • Before Business Rule: When you create the Problem ticket in a "Before" Business Rule, it ensures that the Problem ticket creation is part of the Incident creation transaction. If the Incident fails to be saved for any reason, the Problem ticket creation will also be rolled back.

  • After Business Rule: When the same script is used in an "After" Business Rule, it creates the Problem ticket only after the Incident is successfully saved. This is useful if you want to ensure that the Incident has been committed before any related records are created.

Choosing Between "Before" and "After"

  • Consistency vs. Dependency: If the creation of the Problem ticket should always happen in tandem with the Incident (e.g., if creating a Problem is a business-critical part of the Incident creation), a "Before" Business Rule is appropriate.
  • Asynchronous Needs: If creating the Problem ticket can be done asynchronously or does not need to block the Incident creation, then an "After" Business Rule is suitable.

Given the script works in both, you'll want to consider the business requirements:

  • Use Before if the Problem creation is tightly coupled with the Incident creation.
  • Use After if you prefer to ensure that the Incident is created first, and then create the Problem ticket without holding up the Incident creation process.
 



Choosing Between "Before" and "After"

  • Consistency vs. Dependency: If the creation of the Problem ticket should always happen in tandem with the Incident (e.g., if creating a Problem is a business-critical part of the Incident creation), a "Before" Business Rule is appropriate.
  • Asynchronous Needs: If creating the Problem ticket can be done asynchronously or does not need to block the Incident creation, then an "After" Business Rule is suitable.

Given the script works in both, you'll want to consider the business requirements:

  • Use Before if the Problem creation is tightly coupled with the Incident creation.
  • Use After if you prefer to ensure that the Incident is created first, and then create the Problem ticket without holding up the Incident creation process.
--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

ļ”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ļ”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/