Comprehensive Solution for Sprint Workflow Rule
Your custom workflow rule needs refinement across all four focus areas to handle iteration scoping properly:
1. Custom Workflow Rules - Iteration Boundary Detection
Modify your rule to detect iteration close scenarios by checking if the story is being moved between iterations:
if (story.ScheduleState === 'Completed' && story.Iteration) {
if (story._PreviousValues && story._PreviousValues.Iteration !== story.Iteration) {
return true; // Allow transition during iteration moves
}
// Continue with validation for normal transitions
}
2. WSAPI Queries - Robust Task Calculation
Your task completion logic needs defensive checks:
let tasks = story.Tasks || [];
if (tasks.length === 0) return true; // No tasks = allow transition
let completed = tasks.filter(t => t.State === 'Completed').length;
let taskCompletion = completed / tasks.length;
return taskCompletion >= 0.8;
3. State Transitions - Conditional Validation
Add logic to differentiate between user-initiated and system-initiated transitions. Check if the update includes a “_SystemUpdate” flag or if multiple state changes occur simultaneously (typical of bulk iteration operations). For user-driven transitions during active sprints, enforce the 80% rule strictly. For system operations during sprint close, allow more flexibility.
4. Iteration Scoping - Time-Based Bypass
Implement a 48-hour grace period before iteration end:
let iterationEnd = new Date(story.Iteration.EndDate);
let now = new Date();
let hoursUntilEnd = (iterationEnd - now) / (1000 * 60 * 60);
if (hoursUntilEnd <= 48) return true; // Bypass validation near sprint end
Implementation Strategy:
Combine these approaches into a single rule that checks conditions in priority order: (1) iteration boundary detection first, (2) time-based bypass second, (3) task validation last. This ensures your compliance requirements are met during normal sprint work while preventing workflow blockages during iteration transitions.
Test the updated rule in a sandbox workspace first, focusing on sprint close scenarios. Monitor validation errors in the first sprint cycle and adjust the 48-hour window if needed. Your sprint velocity should normalize once stories can transition freely during iteration boundaries while maintaining validation rigor during active development.
The key insight: workflow rules should understand sprint lifecycle phases, not just individual story state. By adding iteration context awareness, your rule becomes sprint-cadence friendly while preserving the audit controls your compliance team requires.