π 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:
- 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
- Name:
- 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);
- 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 inchange_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.