How to link Change task to its parent Change request
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 09:28 PM
Hi Guys,
Is it possible to link the Change Request to Change tasks that is created using data source?
and if yes, is there any steps or documentation that can help me to achieved this.
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:00 PM
You can link Change Requests to Change Tasks that are created using a data source. This is typically achieved through automation and business rules within ServiceNow.
To accomplish this, you would generally follow these steps:
Create a Data Source: First, ensure that you have set up a data source properly in ServiceNow. This could be a database, an API, or any other source where your change tasks are being generated from.
Create a Business Rule or Script: You would then create a business rule or a script that triggers whenever a new change task is created using the data source. This rule/script will include the logic to link the newly created change task to the appropriate change request.
Define Linking Logic: Within your business rule or script, you'll define the logic to identify which change request the newly created change task should be linked to. This could involve querying related data or using specific identifiers.
Link the Change Task to Change Request: Once you have identified the appropriate change request, you'll use ServiceNow APIs or built-in functions to establish the link between the change task and the change request.
Testing and Validation: Finally, thoroughly test your implementation to ensure that change tasks are being linked correctly to their corresponding change requests.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:05 PM
Hi @Codi
yes, it is possible, after data is imported into staging table, you can simply create a Business Rule that triggers when the data import is complete.
Table: Your staging table name.
When to run: After insert
if (current.u_change_request_number.nil()) {
gs.info("No Change Request Number provided for staging record, cannot link task. Record Sys ID: " + current.sys_id);
return;
}
// Lookup the Change Request based on the provided Change Request Number
var cr = new GlideRecord('change_request');
cr.addQuery('number', current.u_change_request_number);
cr.query();
if (cr.next()) {
// Change Request found, proceed to create and link Change Task
var ct = new GlideRecord('change_task');
ct.initialize();
ct.short_description = current.u_short_description; // Assuming you have similar fields
ct.description = current.u_description; // Ditto
ct.change_request = cr.sys_id; // Link the Change Task to the found Change Request
// You can set additional fields here as needed
var ctSysId = ct.insert(); // Creates the Change Task
gs.info("Change Task created and linked to Change Request " + cr.number + " | Task Sys ID: " + ctSysId);
} else {
// Handle cases where no matching Change Request is found
gs.warn("No matching Change Request found for number: " + current.u_change_request_number);
}
Replace u_change_task_staging, u_change_request_number, u_short_description, and u_description with the actual names of your staging table and fields.
Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 08:44 PM - edited 04-23-2024 09:17 PM
Hi @Deepak Shaerma for the script that you provided which part of it can say's that it is the correct change request for the newly created tasks?
because the change request is already created separately before the creation of bulk change task