Category: Scenario-Based Questions PART 34
Updated on: August 12, 2025  |  0

Scenario-Based Questions PART 34

πŸŽ“ Scenario-Based Question

Β 

πŸ”„ Use Case: Auto-Create Change Request When Incident is On Hold Awaiting Change

This use case ensures that whenever an Incident is set to On Hold (3) with On Hold Reason = Awaiting Change, the system automatically creates a Normal Change Request with relevant details copied from the incident.


πŸ›  Steps to Implement:

  1. Create a Business Rule
    • Name: ABC
    • Table: incident
    • Active βœ…
    • Advanced βœ…
    • When to Run: After Update
    • Filter Conditions:
      • State changes to β†’ On Hold
      • On Hold Reason β†’ Awaiting Change
  2. Write the Script
    (function executeRule(current, previous /*null when async*/) {
    
        var incGR = new GlideRecord('change_request');
        incGR.initialize();
        incGR.setValue('type', 'Normal');
        incGR.setValue('requested_by', current.caller_id);
        incGR.setValue('category', current.category);
        incGR.setValue('short_description', current.short_description);
        incGR.setValue('description', current.description);
        incGR.setValue('cmdb_ci', current.cmdb_ci);
        incGR.insert();
    
        gs.addInfoMessage("πŸ†• Change Request: " + incGR.number + 
                          " has been created for this Incident.");
    
    })(current, previous);
          
  3. Test the Rule
    • Open an Incident and change its state to On Hold.
    • Set On Hold Reason to Awaiting Change.
    • Save/Update the incident.
    • βœ… You will see an info message with the new Change Request number.
    • Verify in the change_request table that the record is created with the same details.

πŸ’‘ Pro Tips:

  • Ensure the type field in change_request accepts "Normal" as a valid value.
  • Consider adding incGR.short_description = "Generated from Incident " + current.number for better tracking.
  • You can extend this script to automatically link the new Change Request back to the Incident for traceability.

Comments

No comments yet.


Log in to post a comment