How to close catalog task after change request state is closed ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 08:32 AM
Hi Team,
Good Day,
I created Normal change Request from the catalog task by using UI Action , Now i have three requirements
1. how to Make relation between Change request and catalog Task.
2. catalog task should be closed once Change is closed.
3. how to add worknotes in change request ex..
- Created from Task.
Thank You.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2024 10:01 PM
To implement your requirements for linking a Normal Change Request to a Catalog Task in ServiceNow, follow these steps:
1. Create a Relationship Between Change Request and Catalog Task
You can create a reference from the Catalog Task to the Change Request by updating the Catalog Task record when you create the Change Request. Here’s how to do it in a UI Action:
// UI Action Script
function createChangeRequest() {
var changeRequest = new GlideRecord('change_request');
changeRequest.initialize();
changeRequest.short_description = 'Change created from Catalog Task';
// Set other required fields
changeRequest.insert();
// Assuming `current` is the Catalog Task record
current.change_request = changeRequest.sys_id; // Create reference
current.update();
}
2. Automatically Close Catalog Task When Change is Closed
You can use a Business Rule to automatically close the Catalog Task when the associated Change Request is closed. Here’s a sample Business Rule:
- Table:
change_request
- When: After
- Condition:
current.state.changesTo('closed')
(or however you define "closed")
Script:
// Business Rule Script
if (current.change_request) {
var catalogTask = new GlideRecord('sc_task');
if (catalogTask.get(current.change_request)) {
catalogTask.state = 'closed'; // Set to Closed state
catalogTask.update();
}
}
3. Add Worknotes to the Change Request
You can add work notes to the Change Request from the Catalog Task using a script. Here's an example you can include in your UI Action or Business Rule:
// Adding work notes to the Change Request
if (current.change_request) {
var changeRequest = new GlideRecord('change_request');
if (changeRequest.get(current.change_request)) {
changeRequest.work_notes = 'Created from Task.';
changeRequest.update();
}
}
Summary of Implementation
- Link Change Request and Catalog Task: Use a UI Action to create a Change Request and store the reference in the Catalog Task.
- Close Catalog Task on Change Closure: Set up a Business Rule to close the Catalog Task when the Change Request is closed.
- Add Worknotes: Update the Change Request with work notes when necessary.
These implementations will help establish a robust relationship between your Change Requests and Catalog Tasks. Let me know if you need further clarification or assistance!