copy the description of a scrum task to another scrum task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 03:01 PM
Hi! I'm working on a workflow where there is a story. The story has several scrum tasks and I need the description of the first scrum task to be copied with scripting to the description of the second scrum task.
I'll be leaving a screenshot of the work flow and the code I have so far, which is not copying anything.
Thanks in advance!
var parent = current.sys_id;
task.parent = parent;
// Get the sys ID of the story
var storySysId = parent;
// Get the sys ID of the first and second tasks
var firstTask = new GlideRecord('rm_scrum_task');
firstTask.addQuery('story', storySysId);
firstTask.orderBy('sys_created_on');
firstTask.query();
if (firstTask.next()) {
var firstDescription = firstTask.description.toString();
}
var secondTask = new GlideRecord('rm_scrum_task');
secondTask.addQuery('story', storySysId);
secondTask.orderByDesc('sys_created_on');
secondTask.query();
if (secondTask.next()) {
secondTask.description = firstDescription;
secondTask.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 09:39 PM
Hi @santiago_bergal ,
Please try with below script:
var parent = current.sys_id;
task.parent = parent;
// Get the sys ID of the story
var storySysId = parent;
// Get the sys ID of the first and second tasks
var firstTask = new GlideRecord('rm_scrum_task');
firstTask.addQuery('story', storySysId);
firstTask.orderBy('sys_created_on');
firstTask.query();
if (firstTask.next()) {
var firstDescription = firstTask.description.toString();
}
var secondTask = new GlideRecord('rm_scrum_task');
secondTask.addQuery('story', storySysId);
secondTask.orderByDesc('sys_created_on');
secondTask.query();
if (secondTask.next() && firstDescription) {
secondTask.description = firstDescription;
secondTask.update();
}
If my response helps you to resolve the issue close the question by ✅Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 09:47 PM
update as this
var parent = current.sys_id;
task.parent = parent;
// Get the sys ID of the story
var storySysId = parent;
var firstDescription;
// Get the sys ID of the first and second tasks
var firstTask = new GlideRecord('rm_scrum_task');
firstTask.addQuery('story', storySysId);
firstTask.orderBy('sys_created_on');
firstTask.query();
if (firstTask.next()) {
firstDescription = firstTask.description.toString();
var secondTask = new GlideRecord('rm_scrum_task');
secondTask.addQuery('story', storySysId);
secondTask.orderByDesc('sys_created_on');
secondTask.query();
if (secondTask.next()) {
secondTask.description = firstDescription;
secondTask.update();
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 01:39 AM
Thanks @Ankur Bawiskar ! I'm afraid this is still not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 01:40 AM
are you sure your query is getting the 1st task correctly?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader