Not able to copy change number to change task in workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2023 07:33 AM
I have a requirement to create ritm through catalog item and from RITM change is created and from change change task.
Everything i have done using workflow and linked RITM to change req using below code in create task activity.
task.u_parent_requested_item =current.sys_id;
Now to link change req and change task the below code is not working in workflow
task.change_request =current.sys_id;
Please help in assigning change number to change task.
On change request form in the related list tab need respective change tasks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2023 08:14 AM
I think my script should work looking at the workflow do one thing add a timer activity of 1 minutes between the two task so that when it goes to create the change task the change request is already there
But if the above does not work please use the below in the task where you are creating change request use the below to store the sys_id
worfklow.scratchpad.var1 = task.sys_id;
And then in the change task activity use the below:-
var value = worfklow.scratchpad.var1;
task.change_request=value;
Please mark my answer as correct based on Impact

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2023 08:14 AM
Try this code and see if it works.
task.description = 'Before activities' ;
var gr=new GlideRecord('change_request');
gr.addQuery('u_parent_requested_item',current.sys_id+'');
gr.query();
if(gr.next())
{
task.change_request=gr.getValue('sys_id');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2023 08:52 AM
Thanks for the inputs.
Both techniques didn't worked.
Can we achieve through BR, like only updating the change number field of change task and linking them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2023 08:56 AM
Hello,
By BR you will not be able to link them as you will not be aware which CR to pick. Can you open the activity of both the CR and change task and show me what code you have written paste a screenshot of that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2023 09:01 AM
However one way is to create the change task itself from the BR. What you can do is create a after insert BR on change request table and if the change request associated RITM is for this catalog item you can just create the change task from the BR and associate it with the request that would work.
Please mark my answer as correct based on Impact.