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

@krishna_1B 

 

Did you get a chance to review this ?

 

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

 

Thanks,

Bhuvan

RaghavSh
Kilo Patron

This seems more of a interview question. It can have multiple answers.

 

1. A before operation BR can insert the record in incident table.

2. Trigger an custom event from the same BR and pass current record sys_id as parameter of event.

3. Write the script action (which refers event created / triggered) to delete the record ads event has the sys_id as parameter.


Raghav
MVP 2023
LinkedIn

pranita-24
Giga Guru

Hi

  • Technically yes — you can call current.deleteRecord() in a before insert or after insert BR.

    Example in Before Insert BR:

     
    if (current.impact == 1 && current.urgency == 1 && current.priority == 1) {
    gs.addInfoMessage("P1 incidents are not allowed.");
    current.setAbortAction(true); // prevents insert }


    This will block the record from being created at all (safer than creating then deleting).

  • If you use an After Insert BR and do current.deleteRecord(), the record will get created, then immediately deleted.

Best practice

If the rule is “No P1 incidents allowed,” the cleanest way is to abort insert in Before BR rather than creating then deleting.
That way the user gets a clear message, and you don’t risk data inconsistencies.

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