# Run On-Demand Workflow

The "Run On-Demand Workflow" action executes a workflow when a user clicks an action button. The action waits for the workflow to fully complete before proceeding to any subsequent actions, making it perfect for multi-step processes that require workflow logic.

## What Are On-Demand Workflows?

On-demand workflows are workflows that don't trigger automatically—they only run when explicitly invoked. Unlike automated workflows (triggered by record creation, updates, or comments), on-demand workflows wait for user action.

Learn more about creating on-demand workflows in the [On-demand workflows guide](/workflows/workflows/on-demand-workflows.md).

## When to Use Run On-Demand Workflow

Use this action when you need to:

* **Execute complex business logic**: Run calculations, validations, or data transformations
* **Trigger external integrations**: Call APIs, send webhooks, or sync with external systems
* **Process related records**: Loop through related records and perform batch operations
* **Send notifications**: Email multiple stakeholders or send custom alerts
* **Generate documents**: Create PDFs, reports, or export data
* **Chain with other actions**: Combine workflow logic with record updates or navigation

## Setting Up Run On-Demand Workflow Action

### Step 1: Create an On-Demand Workflow

Before setting up the action button, create your workflow:

1. Navigate to **Workflows** in your app
2. Create a new workflow
3. **Trigger Type**: Select **On-demand**
4. **Table**: Choose which table type this workflow operates on
5. Add workflow actions (send emails, update records, call webhooks, etc.)

### Step 2: Create the Action Button

1. In build mode, navigate to the record page where you want the button
2. Click the "+" button in the Action Buttons section
3. Click the edit icon to configure the button

### Step 3: Configure Button Appearance

* **Button Text**: Describe what the workflow does (e.g., "Send Reminder", "Generate Report", "Sync to CRM")
* **Appearance**: Choose based on action type (Success for positive actions, Warning for important operations)
* **Icon**: Add relevant icon (e.g., zap/lightning for automation, send for notifications)
* **Button Tooltip**: Explain what will happen when clicked
* **Type**: Choose "One click" for instant execution or "Modal" for confirmation

### Step 4: Configure the Action

**What Should Happen**: Select **Run an on-demand workflow**

**Which Record**:

* **This Record**: Run workflow against the current record
* **Related Record**: Run workflow against a linked single-relationship record (e.g., "This record → Customer")

**Select Workflow**:

* Choose from available on-demand workflows for the selected record type
* Only workflows configured for that table will appear in the list

**Wait for Completion**: The action automatically waits for the workflow to finish before continuing to any subsequent actions.

### Step 5: Configure Notification

* **Notification**: Turn **On** to confirm workflow completion
* **Notification Type**: Usually **Success** (green) or **Information** (blue)
* **Notification Text**: Confirm the action (e.g., "Report generated successfully", "Emails sent")

## Common Use Cases

### 1. Send Email Notifications

**Scenario**: Send a reminder email to a customer

**Workflow Configuration:**

* Trigger: On-demand
* Table: Orders
* Actions:
  1. Send Email to {{record.customer.email}}
  2. Update "Last Reminder Sent" field to {{now}}

**Button Configuration:**

* Button Text: "Send Payment Reminder"
* Icon: Envelope icon
* Type: One click
* Which Record: This record
* Workflow: "Send Payment Reminder Email"
* Notification: "Reminder email sent successfully"

***

### 2. Sync to External System

**Scenario**: Push customer data to external CRM

**Workflow Configuration:**

* Trigger: On-demand
* Table: Customers
* Actions:
  1. Trigger Webhook to CRM API with customer data
  2. Update "Last Synced" field to {{now}}
  3. Update "Sync Status" to "Synced"

**Button Configuration:**

* Button Text: "Sync to Salesforce"
* Icon: Refresh icon
* Type: Modal (confirmation)
* Modal Title: "Sync to Salesforce?"
* Modal Description: "This will send the current customer data to Salesforce."
* Which Record: This record
* Workflow: "Sync Customer to Salesforce"
* Notification: "Customer synced to Salesforce"

***

### 3. Generate Document or Report

**Scenario**: Create a PDF invoice

**Workflow Configuration:**

* Trigger: On-demand
* Table: Orders
* Actions:
  1. Generate PDF with DocsAutomator (invoice template)
  2. Update "Invoice File" field with generated PDF
  3. Send Email with PDF attachment to customer

**Button Configuration:**

* Button Text: "Generate Invoice"
* Icon: Document icon
* Type: Modal
* Modal Title: "Generate Invoice?"
* Which Record: This record
* Workflow: "Generate Order Invoice"
* Notification: "Invoice generated and emailed to customer"

***

### 4. Batch Process Related Records

**Scenario**: Mark all related tasks as complete

**Workflow Configuration:**

* Trigger: On-demand
* Table: Projects
* Actions:
  1. For each Task related to this Project:
     * Update Task Status to "Completed"
     * Update Task Completed Date to {{now}}
  2. Update Project Status to "All Tasks Completed"

**Button Configuration:**

* Button Text: "Complete All Tasks"
* Icon: Check circle icon
* Appearance: Success
* Type: Modal
* Modal Title: "Complete all project tasks?"
* Modal Description: "This will mark all {{record.tasks.count}} tasks as completed."
* Confirm Button Text: "Yes, Complete All"
* Which Record: This record
* Workflow: "Complete All Project Tasks"
* Notification: "All tasks marked as complete"

***

### 5. Complex Approval Process

**Scenario**: Submit for multi-level approval with notifications

**Workflow Configuration:**

* Trigger: On-demand
* Table: Expense Reports
* Actions:
  1. Update Status to "Pending Approval"
  2. Update Submitted Date to {{now}}
  3. Send Email to Manager ({{record.employee.manager.email}})
  4. Only Continue If: Amount > $1000
     * Send Email to Director ({{record.employee.manager.manager.email}})
  5. Create Audit Log record

**Button Configuration:**

* Button Text: "Submit for Approval"
* Icon: Check icon
* Appearance: Success
* Type: Modal
* Modal Title: "Submit Expense Report?"
* Modal Description:

```markdown
## Ready to submit?

**Amount**: ${{record.total_amount}}
**Approver**: {{record.employee.manager.name}}

{{#if record.total_amount > 1000}}
This expense requires director approval (amount over $1,000).
{{/if}}
```

* Which Record: This record
* Workflow: "Submit Expense for Approval"
* Notification: "Expense report submitted for approval"

**Visibility Rule**: Only show when Status = "Draft"

***

### 6. Calculate and Update Fields

**Scenario**: Recalculate commission based on complex rules

**Workflow Configuration:**

* Trigger: On-demand
* Table: Sales
* Actions:
  1. Ask ChatGPT: Calculate commission based on tier, bonus, and region
  2. Update Commission field with calculated value
  3. Update Last Calculated field to {{now}}

**Button Configuration:**

* Button Text: "Recalculate Commission"
* Icon: Calculator icon
* Type: One click
* Which Record: This record
* Workflow: "Calculate Sales Commission"
* Notification: "Commission recalculated: ${{record.commission}}"

***

### 7. Multi-Step Data Cleanup

**Scenario**: Archive a record and its related data

**Workflow Configuration:**

* Trigger: On-demand
* Table: Projects
* Actions:
  1. Update Status to "Archived"
  2. For each Task: Update Task Status to "Archived"
  3. For each Document: Move to Archive folder
  4. Send Email to team: Project archived notification
  5. Create Archive Log record

**Button Configuration:**

* Button Text: "Archive Project"
* Icon: Archive icon
* Appearance: Warning
* Type: Modal
* Modal Title: "Archive this project?"
* Modal Description: "This will archive the project and all related tasks and documents. The project can be unarchived later if needed."
* Which Record: This record
* Workflow: "Archive Project and Related Data"
* Notification: "Project archived successfully"

**Visibility Rule**: Show only for Admin, Project Manager roles

***

### 8. Conditional Workflow Based on Record Data

**Scenario**: Different workflows for different customer types

**Button Text**: "Process Order"

**Workflow Configuration:**

* Trigger: On-demand
* Table: Orders
* Actions:
  1. Only Continue If: Customer Type = "Enterprise"
     * Send Email to Account Manager
     * Create High-Priority Task
  2. Only Continue If: Customer Type = "Standard"
     * Send Standard Confirmation Email
  3. Update Order Status to "Processing"

***

## Combining Workflows with Other Actions

### Multi-Step Action Sequence

**Example**: Update record, run workflow, navigate to next page

**Step 1 - Update Record:**

* Update Status to "Processing"

**Step 2 - Run Workflow:**

* Workflow: "Send Processing Notifications"
* Wait for completion

**Step 3 - Navigate:**

* Navigate to: Processing Queue page

***

### Conditional Next Steps

**Example**: Run workflow, then show message or navigate based on result

**Step 1 - Run Workflow:**

* Workflow: "Validate and Process Data"
* (Workflow updates a "Validation Status" field)

**Step 2 - Show Message** (with visibility rule):

* Only show if: Validation Status = "Failed"
* Message: "Validation failed. Please review the errors."

**Step 3 - Navigate** (with visibility rule):

* Only show if: Validation Status = "Success"
* Navigate to: Success page

***

### Sequential Workflow Execution

Run multiple workflows in sequence:

**Step 1 - Run Workflow:**

* Workflow: "Prepare Data"

**Step 2 - Run Workflow:**

* Workflow: "Sync to External System"

**Step 3 - Run Workflow:**

* Workflow: "Send Confirmation"

Each workflow waits for the previous one to complete.

***

## Running Workflows on Related Records

You can run workflows against linked records:

**Example**: Run workflow on a related customer

**Which Record**: This record → Customer (single-linked field) **Select Workflow**: Choose workflow configured for Customer table

**Use Case**: From an Order record, run a "Update Customer Loyalty Points" workflow on the related customer.

***

## Best Practices

### Workflow Design

* ✅ Keep workflows focused on a single purpose
* ✅ Use clear workflow names that describe the action
* ✅ Add error handling in workflows (Only Continue If conditions)
* ✅ Test workflows thoroughly before deploying
* ✅ Log important workflow executions for audit purposes

### Button Configuration

* ✅ Use descriptive button text that explains what will happen
* ✅ Add confirmation modals for important or irreversible workflows
* ✅ Show clear notifications when workflows complete
* ✅ Set appropriate visibility rules to control who can trigger workflows
* ✅ Use tooltips to provide additional context

### Performance

* ✅ Keep workflows efficient—avoid unnecessary loops or external calls
* ✅ Show loading indicators (automatic when workflow is running)
* ✅ Consider timeout limits for long-running workflows
* ✅ Test with realistic data volumes

### User Experience

* ✅ Provide clear feedback when workflow starts and completes
* ✅ Use modal confirmations for workflows that can't be undone
* ✅ Disable button during execution to prevent duplicate runs
* ✅ Show meaningful success messages with dynamic values

## Troubleshooting

### Workflow Doesn't Appear in List

**Issue**: Can't find the workflow when configuring action

**Solutions**:

* Verify workflow trigger type is set to "On-demand" (not automatic)
* Ensure workflow is configured for the correct table type
* Check if workflow is enabled (not disabled)
* Refresh the page and try again

***

### Workflow Fails to Execute

**Issue**: Workflow doesn't run or shows error

**Solutions**:

* Check workflow execution logs in Workflows section
* Verify all required fields in workflow are populated
* Test workflow manually using "Test" button in workflow builder
* Check for permission issues (user must have permissions for workflow actions)
* Review workflow conditions (Only Continue If might be blocking)

***

### Action Button Shows Error

**Issue**: Button click results in error message

**Solutions**:

* Verify the record exists and is accessible
* Check that user has permission to trigger workflows
* Ensure related record exists (if running workflow on related record)
* Review workflow for errors in configuration

***

### Workflow Runs But Changes Don't Show

**Issue**: Workflow completes but changes aren't visible

**Solutions**:

* Refresh the page to see updates
* Check if workflow updated a different record than expected
* Verify workflow actions are configured correctly
* Review workflow execution logs to confirm actions ran

***

### Long-Running Workflows

**Issue**: Workflow takes a long time or times out

**Solutions**:

* Optimize workflow to reduce external API calls
* Reduce the number of loops or batch operations
* Consider splitting into smaller workflows
* Check if external services are slow or unavailable
* Review workflow timeout settings

***

### Related Record Not Found

**Issue**: Can't run workflow on related record

**Solutions**:

* Verify the relationship field is populated (not empty)
* Check that it's a single-relationship field (not multi-relationship)
* Ensure related record hasn't been deleted
* Use visibility rules to hide button when relationship is empty

***

## Advanced Patterns

### Workflow Orchestration

Create a "master" workflow that triggers multiple other workflows:

**Master Workflow Actions:**

1. Run Workflow: "Step 1 - Validate Data"
2. Only Continue If: Validation Passed
3. Run Workflow: "Step 2 - Process Data"
4. Run Workflow: "Step 3 - Send Notifications"

***

### Error Handling

Build robust error handling into workflows:

**Workflow Actions:**

1. Update "Processing Status" to "In Progress"
2. \[Try main workflow actions]
3. Only Continue If: \[Success condition]
   * Update "Processing Status" to "Complete"
4. Only Continue If: \[Failure condition]
   * Update "Processing Status" to "Failed"
   * Send Email to Admin with error details

***

### User Input Before Workflow

Collect user input, then run workflow:

**Step 1 - Update Record:**

* Show fields: "Approval Notes", "Approved Amount"
* User fills in information

**Step 2 - Run Workflow:**

* Workflow uses the user-provided values
* Workflow: "Process Approval with Notes"

***

### Conditional Workflow Selection

Use visibility rules to show different buttons that run different workflows:

**Button 1** (show when Priority = "High"):

* Text: "Expedite Processing"
* Workflow: "High Priority Processing"

**Button 2** (show when Priority = "Normal"):

* Text: "Standard Processing"
* Workflow: "Standard Processing"

***

## Security and Permissions

### Workflow Permissions

* Workflows run with the permissions of the user who triggers them
* Users need appropriate table permissions for workflow actions
* Some actions (like sending emails) may require specific permissions

### Action Button Visibility

* Use visibility rules to control who can trigger workflows
* Hide sensitive workflows from unauthorized users
* Consider role-based restrictions for critical workflows

### Audit Logging

* Log important workflow executions
* Track who triggered workflows and when
* Store workflow results for compliance and debugging

***

## Performance Considerations

### Workflow Optimization

* Minimize external API calls
* Use batch operations when possible
* Avoid deeply nested loops
* Cache frequently accessed data

### User Experience

* Show progress indicators (automatic)
* Provide estimated completion time for long workflows
* Allow cancellation of long-running workflows (if supported)
* Don't block UI for very long operations

***

## Testing On-Demand Workflows

### Before Production

1. **Test workflow independently**: Use workflow "Test" button
2. **Test with action button**: Verify integration works correctly
3. **Test different scenarios**: Various record states, different users
4. **Test error cases**: Missing data, failed API calls, timeouts
5. **Test notifications**: Verify success messages display correctly

### Monitoring in Production

* Review workflow execution logs regularly
* Monitor for failed executions
* Track execution times
* Collect user feedback on workflow behavior


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://guides.noloco.io/actions/action-buttons/run-on-demand-workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
