Prevent closing singleTAsk or parent project task based on child attachment validation (Workspace)

priyanka42m
Kilo Contributor

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

  1. Standalone Task (no parent and no child)

    • Task should NOT be allowed to close without attachment

  2. Parent has attachment, but child does NOT

    • Parent should NOT be allowed to close

  3. 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

  1. Why does setAbortAction(true) not block save in Workspace?

  2. What is the recommended approach for this scenario:

    • Business Rule

    • Client Script

    • Script Include (combined approach?)

  3. 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!

0 REPLIES 0