create an error or stop submission during blackout schedule

RBlor
Mega Guru

i have a blackout schedule during a change request period but i would like to make so it displays an error if done during a blackout perioud  or blocks the submission. I was told this could be done via business rule but i dont  know how to go about that. can anyone assist

10 REPLIES 10

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @RBlor 

 

Greetings!!

I am not a pro or coder but there is OOTB message displayed which state change is in conflict. Will not that work for you? Because if you put error message then change will not proceed and even it most urgent it block the process. I request please take the worse use case if we put an error message what will be be action / impact on change record.

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

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

unfortunately the request is to abort because so many CRs try to get pushed before calendar close

 

Revanth Karra
Tera Expert

Dear RBlor,

 

@RBlor , hope you're doing great!

 

To create a business rule to block change requests during a blackout period, you can follow these steps:

  1. Go to System Definition > Business Rules.
  2. Click New.
  3. In the Name field, enter a name for the business rule, such as Block change requests during blackout period.
  4. In the Table field, select Change Request.
  5. In the Condition field, enter the following condition:

BLACKOUT_START_DATE <= current.planned_start_date AND current.planned_start_date <= BLACKOUT_END_DATE

This condition will check if the planned start date of the change request is within the blackout period.

     6. In the Script field, enter the following script:

 

gs.addErrorMessage("Change requests cannot be created during a blackout period.");
current.setAbortAction(true);

 

 

This script will display an error message and abort the change request if it is created during a blackout period.

    7. Click Save.

 

Once you have created the business rule, it will be activated automatically. Any change requests that are created during a blackout period will be aborted.

You can also use a business rule to display an error message to the user if they attempt to create a change request during a blackout period. To do this, you can modify the script in the above example as follows:

 

gs.addInfoMessage("Change requests cannot be created during a blackout period. Please try again later.");

 

 

Note:

This script will display an info message to the user, but it will not abort the change request. The user will still be able to create the change request, but they will be aware that it will not be processed until the blackout period is over.

 

Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!

 

Thanks & Regards, 

Revanth. K

Product Test Automation Engineer

Hi @Revanth Karra thank you for the reply. 

 

I recieved the following error: JavaScript parse error at line (1) column (54) problem = missing ; before statement (<refname>; line 1)

the condition written was:
BLACKOUT_START_DATE <= current.planned_start_date AND current.planned_start_date <= BLACKOUT_END_DATE;