Prevent closing singleTAsk or parent project task based on child attachment validation (Workspace)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Module: SPM (Project Management)
Table: pm_project_task
Interface: Workspace
Requirement
Project Tasks can exist as standalone records or in a parent-child hierarchy.
I need to restrict closing of tasks when:
u_activity = deliverables
AND state changes to Closed states (3, 4, 7)
Use Cases
Standalone Task (no parent and no child)
❌ Task should NOT be allowed to close without attachment
Parent has attachment, but child does NOT
❌ Parent should NOT be allowed to close
Child has attachment, but parent does NOT
✔ Child can be closed
❌ Parent should NOT be allowed to close
Expected Behavior
A task should only be allowed to close if:
It has attachment (for standalone task)
OR (in case of hierarchy):
Parent has attachment
AND all child tasks also have attachments
If validation fails:
Save should be prevented
Error message should be displayed
What I Have Tried
Attempt 1: Business Rule Approach
Implemented a Before Business Rule to:
Validate attachment for single task
Handle parent-child validation logic
Issue:
current.setAbortAction(true) is not working in Workspace
Record still gets saved even when validation fails
Attempt 2: Client Script Approach
Created a field u_coc (type: File Attachment) on Project Task
Implemented an onChange Client Script on State field (when changing to 3, 4, 7)
Making u_coc field mandatory
Issue:
Works only for individual task
Does NOT handle parent-child validation logic
Issue
Unable to enforce validation consistently in Workspace
Need a solution that:
Works for both standalone and parent-child hierarchy
Properly prevents record save
Handles attachment validation across related records
Questions
Why does setAbortAction(true) not block save in Workspace?
What is the recommended approach for this scenario:
Business Rule
Client Script
Script Include (combined approach?)
How can we efficiently:
Validate attachments on parent and all child tasks
Prevent closing accordingly
Additional Info
Table: pm_project_task
Parent field: parent
Attachments stored in: sys_attachment
Thanks in advance!
