I need to create Change Task after RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 11:02 PM
Good morning.
I have a requirement, that on the Catalog form, we have a Change Request field. So, before submitting the form, the user should have created a Change Request first, then only he can fill out the form.
Once form is submitted, RITM gets created and under it, we need to create Change Task, instead of SCTASK.
I have achieved this using scripting in workflow. But the problem is, Change Task is getting created under the Change Request, which we created earlier, but not under RITM. But it should also get attached on the RITM>Change Task.
How to achieve this?
The script is below which works but Change Task is not getting attached on the RITM, (although it getting attached under the Change Request).
WorkFlow Run Script 1:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 11:36 PM
I believe you need to associate parent field of that change task to RITM then you would be able to see it
for example.
Create a business rule on Requested ITem table (sc_req_item) in which you would be coding change_task like below:
(function executeRule(...........) {
// Ensure the script runs for the RITM table
if (current.getTableName() === 'sc_req_item') {
var changeTask = new GlideRecord('change_task'); // Create a new Change Task record
changeTask.initialize();
// Set mandatory and additional fields
changeTask.parent = current.sys_id; // Associate Change Task under the RITM
changeTask.short_description = 'Change Task for RITM ' + current.number; // Short Description
changeTask.description = 'Created for Request Item: ' + current.number; // Description
changeTask.assignment_group = current.assignment_group; // Match Assignment Group to RITM
changeTask.assigned_to = current.assigned_to; // Match Assignee to RITM if exists
// Example date fields (adjust as necessary)
changeTask.start_date = current.variables.start_date || gs.nowDateTime();
changeTask.end_date = current.variables.end_date || gs.daysAgoStart(5);
// Insert the Change Task
changeTask will insert update assential fields
Try something like above and see if it works.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 12:47 AM
Thank you so much @Ct111 . Helped a lot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2025 11:37 PM
To achieve the goal of creating a Change Task under both the Change Request and the RITM, you need to link the Change Task to the RITM in addition to the Change Request. This can be done by setting the RITM field on the Change Task record.
you can modify your second script to achieve this:
workflow.info('Run Script Checking 3' + current.variables.change_request_number_1);
workflow.info('workflow.scratchpad.appName' + workflow.scratchpad.appName);
// Get the Change Request using the provided sys_id
var gr = new GlideRecord('change_task');
gr.addQuery('change_request', current.variables.change_request_number_1);
gr.query();
if (gr.next()) {
gr.initialize();
// Set the Change Request
gr.setValue('change_request', current.variables.change_request_number_1);
// Set the RITM (this is the key change)
gr.setValue('u_application', workflow.scratchpad.appName);
gr.setValue('assignment_group', '58c5a8940f3c62407b3a3e7ce1050ed2');
gr.setValue('short_description', 'Change Task has been created for Assignment group AP Digital Products Support');
// Link Change Task to the RITM
gr.setValue('u_ritm', current.sys_id); // Make sure 'u_ritm' is the correct reference field to link Change Task to RITM
// Insert the Change Task record
gr.insert();
}
- u_ritm should be the reference field on the Change Task table that links the Change Task to the RITM. If you don’t have this field already, you will need to create it as a reference field to the RITM table.
- The current.sys_id refers to the current record, which is your RITM record (the catalog request).
Verify that u_ritm is the correct field name. You may need to adjust this to match the reference field in your Change Task table that is designed to link to the RITM. If RITM is not a custom field but a standard field, it might be referenced as request_item (standard field for RITM)
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2025 12:48 AM
Thank you so much @Rajesh Chopade1 . Helped a lot.