Custom JS action not triggering on workflow automation form

I’ve configured a custom JavaScript action in a workflow automation form (AEC 2021), but it’s not executing when the workflow reaches that step. The workflow progresses past the form step without errors, but the custom JS action is completely skipped.

The action is set up in the workflow designer:

workflow.addAction('custom-js', {
  script: 'validateLeadScore',
  trigger: 'onFormSubmit'
});

When I test the script directly in the browser console, it works fine. But in the workflow context, it never runs. The workflow automation logs show the form step as completed, but there’s no indication the JS action was attempted. Is there a specific form event binding or workflow configuration needed for custom JS actions to execute properly?

This is a common issue with custom JavaScript actions in AEC 2021 workflow automation. The problem stems from how workflow actions are bound to form events and executed within the workflow engine context. Here’s what you need to fix:

1. Form Event Binding Your current code uses ‘onFormSubmit’ as the trigger, but this event binding doesn’t exist in the workflow automation context. AEC 2021 workflows use a different event model than standalone forms:

workflow.addAction('custom-js', {
  script: 'validateLeadScore',
  trigger: 'workflow.step.complete',
  executionContext: 'client'
});

The key changes:

  • trigger: 'workflow.step.complete' - This is the correct workflow-level event that fires after form submission
  • executionContext: 'client' - Specifies that the script should run in the browser context (default is ‘server’, which has different API access)

2. Workflow Automation Logs Custom JS actions that fail silently usually have execution errors that only appear in the workflow automation logs, not the browser console. To view these:

  • Navigate to Workflow Automation → Monitoring → Execution Logs
  • Filter by your workflow name and date range
  • Look for entries with type ‘CustomActionExecution’
  • Expand the log entry to see the detailed error message

Common errors include:

  • Script not found in registry (script name mismatch)
  • Insufficient permissions to execute custom scripts
  • Timeout errors (default timeout is 5 seconds)
  • Sandbox violations (accessing restricted APIs)

3. JS Action Execution Requirements For custom JS actions to execute properly in workflows, you need to complete these setup steps:

Step 1: Register the script

// In Workflow Automation → Scripts → Custom Actions
// Register your script with proper metadata
{
  name: 'validateLeadScore',
  description: 'Validates lead score before workflow proceeds',
  version: '1.0',
  timeout: 10000,
  requiredPermissions: ['workflow.execute', 'data.read']
}

Step 2: Configure form data binding The script needs access to form data. In your workflow step configuration:

workflowStep.setDataBinding({
  formData: 'step.input.formData',
  outputVariable: 'leadScoreValidation'
});

Step 3: Update the action registration

workflow.addAction('custom-js', {
  script: 'validateLeadScore',
  trigger: 'workflow.step.complete',
  executionContext: 'client',
  inputMapping: {
    formData: '${step.input.formData}',
    currentScore: '${lead.score}'
  },
  outputMapping: {
    isValid: 'leadScoreValidation.isValid',
    validationMessage: 'leadScoreValidation.message'
  }
});

The input/output mapping tells the workflow engine how to pass data to your script and where to store the results.

Testing and Debugging:

  1. Enable verbose logging: Workflow Settings → Debug Mode → Enable
  2. Test the workflow with a single instance to see detailed execution logs
  3. Verify the script executes: Check for ‘Script executed successfully’ in logs
  4. If the script still doesn’t run, check user permissions: Admin Console → Roles → Workflow Automation → Custom Script Execution

Common Pitfalls:

  • Script name in addAction() must exactly match the registered script name (case-sensitive)
  • The workflow must be republished after adding custom actions (draft changes don’t affect running workflows)
  • Form-based triggers like ‘onFormSubmit’ only work in standalone forms, not workflow forms
  • Client-side execution context has access to browser APIs but not to server-side workflow variables

If you’re still having issues after these changes, share the workflow automation log entries for the specific workflow instance, and I can help diagnose the exact failure point.

The trigger might be wrong. ‘onFormSubmit’ is a form-level event, but workflow actions execute at the workflow step level, not the form level. Try changing the trigger to ‘onStepEnter’ or ‘onStepComplete’ instead. The workflow engine processes step-level events, while form events are handled by the form controller, which might not be integrated with your workflow step.

I’ve seen this happen when the custom JS action is added to a workflow step that doesn’t have form data available. If your workflow step doesn’t actually render a form (e.g., it’s an automatic step or uses a pre-filled form), the form event bindings won’t work. Check the workflow step configuration to ensure it’s set to ‘User Input Required’ and that a form template is assigned to the step. Without an actual form interaction, form-based triggers never fire.