When defect is created under parent story, Planned effort of that new defect must get added to story

indrasengupta
Tera Guru

When defect is created under parent story, "Planned effort" of that new defect must get added to story "Planned effort", currently Out of the box functionally replaces the "Planned effort" of story with "Planned effort" of defect. I want to get it added instead.

earlier story story had "Planned effort" 2, but when defect got created "Planned effort" of story got replaced with "Planned effort" of defect.

indrasengupta_0-1744869808880.png


Child defect.

indrasengupta_1-1744869868601.png

 

 

8 REPLIES 8

pratikjagtap
Giga Guru

Hi @indrasengupta ,

 

Try Business rule 

 
Table: rm_defect
When: after insert
Condition: parent is not empty

 

(function executeRule(current, previous /*null when async*/) {
if (!current.parent || !current.planned_effort)
return;

var parent = new GlideRecord('rm_story');
if (parent.get(current.parent)) {
// Add defect's effort to story's effort
var defectEffort = parseFloat(current.planned_effort.toString()); // in seconds
var storyEffort = parseFloat(parent.planned_effort.toString()); // in seconds

var newEffort = storyEffort + defectEffort;

parent.planned_effort = newEffort;
parent.update();
}
})(current, previous);

 

If my response helped, please hit the 👍Thumb Icon and accept the solution so that it benefits future readers.

 

Regards,
Pratik

Did not worked

Shree_G
Kilo Sage

Hello @indrasengupta ,

 

How is defect created? If this is created through an UI action, check for the script in UI Action that updates planned efforts. E.g. below :

 

current.planned_effort = defect.planned_effort   

change to -----> current.planned_effort += defect.planned_effort


If this solution helped resolve your issue, please consider marking it as helpful or correct.
This will assist others in finding the solution faster and close the thread.

I am creating defect from story related list

indrasengupta_0-1744893392887.png