Project task % completion auto update
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 06:56 PM
I require the Project task % completion auto update based on planned and actual effort, I have the following BR however thins is not working, % completion remains unchanged when I have values for planned and actual effort, has anyone done this?
BR details:
- Table: Project Task [pm_project_task]
- When: After
- Insert: True
- Update: True
Condition:
- Condition: Actual Effort changes
(function executeRule(current, previous /*null when async*/) {
// Calculate total planned and actual effort for the project
var projectGr = new GlideRecord('pm_project');
if (projectGr.get(current.project)) {
var totalPlannedEffort = 0;
var totalActualEffort = 0;
// Calculate the total planned and actual effort for each task
var taskGr = new GlideRecord('pm_project_task');
taskGr.addQuery('project', current.project);
taskGr.query();
while (taskGr.next()) {
totalPlannedEffort += taskGr.planned_effort;
totalActualEffort += taskGr.actual_effort;
}
// Update project percent complete based on actual vs planned effort
if (totalPlannedEffort > 0) {
var percentComplete = (totalActualEffort / totalPlannedEffort) * 100;
projectGr.percent_complete = percentComplete;
projectGr.update();
}
}
})(current, previous);
0 REPLIES 0