How to sum up the child story points and update that value in parent story points field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 12:45 AM
Hi Geeks,
I have a use case where there is a single parent story and multiple child story(s) and we have a field called as points under each story.
Whenever any story is added as a child for the parent story, then the points for the child should be summed up and add to parent story.
Initial - Parent story A - 0 points
Added - Child Story B - 3 points to Story A - Parent Story A points should be 3
Added - Child Story C - 5 points to Story A - Parent Story A points should be 8
Added - Child Story D - 3 points to Story A - Parent Story A points should be 11
Removed - Child Story C - 5 points from Story A - Parent Story A points should be 6
Please let me know what will be the logic that I need to implement it via a business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2023 03:58 AM
It would be easiest to wipe out and re-calculate the parent story points each time a story is inserted or deleted, rather than trying to keep a running total, so trigger your Business Rule before Insert and Delete, with the Filter Condition Parent is not empty.
Your script will set the value of a script variable = story_points, then do a GlideRecord on the story table where the parent = current.parent and sys_id != current.sys_id. For each record returned, add the story_points to the script variable. Next do another GlideRecord on the story table to retrieve the parent record. Set the value of story_points to the value of the script variable and remember a .update() since this not the current record. Give the script a shot and post it if you get stuck.