Business Rule: After BR Type Use Case.

Akshay Pithore
Tera Contributor
  1.  After: After business rule runs when record is saved in the database. We can use after business rule to react inserts/updates/deletes.
  • Use Case: Will create the problem ticket through the incident ticket when user change the incident state field value as “on hold”.
  • With Script Scenario:
  • Scenario (Insert): User should see message at the top when story is created.

Steps:

  1. Navigate to All>Business Rule > Create New
  2. Fill all required fields like Name, table (Incident) and active and advanced true.
  3. When to Run
  4. Actions
  5. Advanced

AkshayPithore_0-1751790400575.png

 

AkshayPithore_1-1751790400579.png

 

 

 

 

 

AkshayPithore_2-1751790400583.png

 

 

Scenario (Update): When the priority of incident is changed to P1 Then it should be updated in Description.

Steps:

  1. Navigate to All>Business Rule > Create New
  2. Fill all required fields like Name, table (Incident) and active and advanced true.
  3. When to Run
  4. Actions
  5. Advanced

AkshayPithore_3-1751790400587.png

 

AkshayPithore_4-1751790400589.png

 

AkshayPithore_5-1751790400591.png

 

 

AkshayPithore_6-1751790400595.png

 

  • With Scripting
  • Scenario Insert:  When User should see message at the top when story is created with Number.

Steps:

  1. Navigate to All>Business Rule > Create New
  2. Fill all required fields like Name, table (Incident) and active and advanced true.
  3. When to Run
  4. Actions
  5. Advance
  6. AkshayPithore_7-1751790400597.png

     

    AkshayPithore_8-1751790400599.png

     

    AkshayPithore_9-1751790400603.png
    • Scenario (Update):  When State changes to work in progress then scrum tasks should be created.

    Steps:

    1. Navigate to All>Business Rule > Create New
    2. Fill all required fields like Name, table (Incident) and active and advanced true.
    3. When to Run
    4. Actions
    5. Advanced

     

    AkshayPithore_10-1751790465724.png

     

    AkshayPithore_11-1751790465726.png

     

    AkshayPithore_12-1751790465728.png

     

     

     

     

     

     Async Business Rule: Async Business Rule is triggered when user submits the form, and any action is taken on the record in the database however it creates a schedule and runs the job.

    • Major use case of Async BR
    • Create event
    • Send Rest API call to another application on update of incident.
    • Calculating SLAs
    • In Async cannot use changes(),changesTo(),and changesFrom method
    • Async with scripting:

     

     

    • Scenario (Insert): When incident is inserted with priority 1 then create an event to send notification.

    Steps:

    (function executeRule(current, previous /*null when async*/) {

     

        // Add your code here

         gs.eventQueue('incident.p1.inserted',current,current.assignment_group.assigned_to);

    })(current, previous

     

     

    AkshayPithore_13-1751790465729.png

     

     

    AkshayPithore_14-1751790465731.png

     

    AkshayPithore_15-1751790465732.png

     

                                                        

    AkshayPithore_16-1751790465735.png

     

     

    AkshayPithore_17-1751790465736.png

     

     

    • Scenario (Update): When Assignment group changes then update the task SLA group to current

    Assignment group.

    Steps:

    (function executeRule(current, previous /*null when async*/) {

     

        // This business rule updates the 'u_group' field in the 'task_sla' table

        // with the 'assignment_group' value from the related task.

       

        // Initialize a GlideRecord object for the 'task_sla' table

        var gr = new GlideRecord('task_sla');

       

        // Add a query to filter records where the 'Task' field matches the 'sys_id' of the current task

        gr.addQuery('Task', current.sys_id);

       

        // Execute the query to retrieve matching 'task_sla' records

        gr.query();

       

        // Iterate over each matching record

        while (gr.next()) {

            // Set the 'u_group' field of each 'task_sla' record to the 'assignment_group' value of the current task

            gr.u_group = current.assignment_group;

           

            // Update each 'task_sla' record with the modified 'u_group' value

            gr.update();

        }

     

    })(current, previous)

     

     

     

     

     


Please mark this response as correct or helpful if it assisted you with your question.
1 REPLY 1

Mark Manders
Mega Patron

It's clear that the Rising Star application period is open again, because the question section of the Community is flooded with people sharing 'knowledge' without asking questions. Please start your posts with stating it's informative and not a question. That helps the people that come here to answer questions. They don't need to read through entire posts, expecting a question, just to see that someone is just trying to show they are posting.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark