corrad-bp/docs/process-execution/ASSIGNED_PROCESSES.md

4.2 KiB

Assigned Processes Feature

Overview

The "Start New Case" page now displays only processes where the current user is assigned to complete the first form task. This ensures users only see processes they have permission to start.

How It Works

API Endpoint

A new API endpoint /api/process/assigned has been created that:

  1. Authenticates the user - Gets the current user from the request context
  2. Fetches user roles - Retrieves all roles assigned to the current user
  3. Filters processes - Only returns processes where the user is assigned to the first form

Assignment Types

The system checks the assignment configuration of the first form node in each process:

1. Public Assignment (assignmentType: 'public')

  • Access: Anyone can start the process
  • Behavior: Process is included for all users

2. User Assignment (assignmentType: 'users')

  • Access: Only specific users can start the process
  • Check: Current user ID or email must be in assignedUsers array
  • Example:
{
  "assignmentType": "users",
  "assignedUsers": [
    {
      "value": "123",
      "label": "John Doe (john.doe)",
      "username": "john.doe"
    }
  ]
}

3. Role Assignment (assignmentType: 'roles')

  • Access: Only users with specific roles can start the process
  • Check: Current user's roles must match assignedRoles array
  • Example:
{
  "assignmentType": "roles",
  "assignedRoles": [
    {
      "value": "2",
      "label": "Manager"
    }
  ]
}

4. Variable Assignment (assignmentType: 'variable')

  • Access: Dynamic assignment based on process variables
  • Behavior: Currently includes all processes (future enhancement needed)

Frontend Changes

The /execution/new-case page has been updated to:

  1. Use the new API endpoint - Calls /api/process/assigned instead of /api/process
  2. Updated UI - Shows "My Assigned Processes" header and assignment indicators
  3. Better messaging - Clear indication when no processes are assigned

Configuration

Setting Up Process Assignments

  1. Open Process Builder - Navigate to the process you want to configure
  2. Select First Form Node - Click on the first form node in your process
  3. Configure Assignment - In the form configuration modal:
    • Choose assignment type (Public, Users, Roles, or Variable)
    • Select specific users or roles as needed
    • Save the configuration

Example Configuration

{
  "nodes": [
    {
      "id": "form-1",
      "type": "form",
      "data": {
        "label": "Initial Request Form",
        "formId": "123",
        "assignmentType": "roles",
        "assignedRoles": [
          {
            "value": "2",
            "label": "Manager"
          },
          {
            "value": "3", 
            "label": "Supervisor"
          }
        ]
      }
    }
  ]
}

Security Considerations

  • Authentication Required: All requests must be authenticated
  • Role-based Access: Users can only see processes they're assigned to
  • Audit Trail: Process starts are logged with user information

Troubleshooting

No Processes Showing

If a user doesn't see any processes:

  1. Check User Roles - Verify the user has the correct roles assigned
  2. Check Process Assignment - Ensure the first form node has proper assignment configuration
  3. Check Process Status - Process must be published and not deleted
  4. Check Assignment Type - Verify the assignment type is configured correctly

Debug Information

The API endpoint includes console logging for debugging:

// User information
console.log('Current user ID:', currentUser.userID);
console.log('User roles:', userRoleNames);

// Assignment checks
console.log('Checking user assignment:', {...});
console.log('Checking role assignment:', {...});
console.log('Process assignment result:', isAssigned);

Future Enhancements

  1. Variable Evaluation - Implement proper variable-based assignment
  2. Multiple Form Support - Check assignments across multiple form nodes
  3. Permission Inheritance - Support for inherited permissions from parent processes
  4. Bulk Assignment - Tools for bulk assigning processes to users/roles