Skip to main content

Command Palette

Search for a command to run...

Dataverse Actions – Complete Guide with Real-Time Example

Updated
•4 min read•View as Markdown
Dataverse Actions – Complete Guide with Real-Time Example

What are Actions in Microsoft Dataverse?

Actions in Dataverse are custom business operations that let you execute logic on demand.
Unlike workflows that run automatically, actions are explicitly triggered by:

  • A command bar button

  • JavaScript

  • Power Automate

  • Plugins

  • External APIs

Think of an Action as a custom API endpoint inside Dataverse.


Why Do We Need Actions?

Actions are used when:

  • You need manual control over execution

  • Logic should run only when explicitly invoked

  • You want to pass input parameters

  • You want to return output values

  • You want the same logic reused by JS + Power Automate + API

Real-world Use Cases

  • Approve / Reject records

  • Apply business rules manually

  • Trigger validations

  • Calculate values on demand

  • Integration endpoints


Types of Actions

Action TypeDescription
Bound ActionRuns on a specific table record
Unbound ActionRuns globally (no table context)

Your example is a Bound Action.


How to Create an Action (Step-by-Step)

  1. Create Action Process

Go to:

Solutions → New → Process → Action

Configure:

PropertyValue
Process NameApplyBusinessRules
CategoryAction
EntityUser Owned (your table)
Enable RollbackEnabled

  1. Define Input & Output Arguments

https://xrmdynamicscrm.wordpress.com/wp-content/uploads/2020/12/blog-24.png?w=1024&utm_source=chatgpt.com

Input Parameters

NameTypeDirection
IsApprovedBooleanInput
ApprovalCommentStringInput

Output Parameters

NameTypeDirection
ResultStringOutput
MessageStringOutput

  1. Add Logic Inside Action

Example steps:

  • Update record

  • Apply conditions

  • Assign output values

Example:

  • If update column value to Validated

  • Set Result = "Done Completed"

  • Set Message = "Output from action"


How to Run Action Using JavaScript (Command Bar)

JavaScript Web Resource

  1. Create single web resource file.
function runSunApplyBusinessRules(primaryControl) {

    var formContext = primaryControl;

    if (!formContext || !formContext.data || !formContext.data.entity) {
        Xrm.Navigation.openAlertDialog({
            title: "Error",
            text: "Form context not available."
        });
        return;
    }

    var recordId = formContext.data.entity.getId();

    if (!recordId) {
        Xrm.Navigation.openAlertDialog({
            title: "Save Required",
            text: "Please save the record before running this action."
        });
        return;
    }

    recordId = recordId.replace("{", "").replace("}", "");

    var isApproved = true;
    var approvalComment = "Approved from command bar";

    executeSunApplyBusinessRules(recordId, isApproved, approvalComment, formContext);
}
function executeSunApplyBusinessRules(recordId, isApproved, approvalComment, formContext) {

    var request = {
        entity: {
            entityType: "sun_userowned", //table logical name
            id: recordId
        },
        IsApproved: isApproved,
        ApprovalComment: approvalComment,

        getMetadata: function () {
            return {
                boundParameter: "entity",
                parameterTypes: {
                    "entity": {
                        typeName: "mscrm.sun_userowned",  //mscrm.table logical name
                        structuralProperty: 5
                    },
                    "IsApproved": {
                        typeName: "Edm.Boolean",
                        structuralProperty: 1
                    },
                    "ApprovalComment": {
                        typeName: "Edm.String",
                        structuralProperty: 1
                    }
                },
                operationType: 0,
                operationName: "sun_ApplyBusinessRules"   //action logical name
            };
        }
    };

    Xrm.WebApi.online.execute(request).then(
        function (response) {
            if (response.ok) {
                response.json().then(function (data) {

                    var result = data.Result || "Action Completed";
                    var message = data.Message || "Success";

                    Xrm.Navigation.openAlertDialog({
                        title: result,
                        text: message
                    });

                    formContext.data.refresh();
                });
            }
        },
        function (error) {
            Xrm.Navigation.openAlertDialog({
                title: "Action Failed",
                text: error.message
            });
        }
    );
}
  1. Create and activate Process as shown above How to Create an Action (Step-by-Step)

  2. Now open Model driven in edit mode

  3. go to the table where we will add button

  4. Edit command bar as shown in below image

  5. Add button in main form

  6. Add new button

  7. Configure button as shown below

  8. Save and publish

  9. Run the app and go to the table and select run action button.


How to Run Action Using Power Automate

Steps:

  1. Trigger: Manual / When a row is selected

  2. Action: Perform an unbound/bound action

  3. Select:

    • Table name

    • Action name

  4. Pass input parameters:

    • IsApproved

    • ApprovalComment

  5. Capture output:

    • Result

    • Message

Capture output


Actions vs Workflows – When to Use What?

Comparison Table

FeatureActionWorkflow (Classic)
Trigger TypeManual / APIAutomatic
Input ParametersYesNo
Output ParametersYesNo
Can be called from JSYesNo
Can be called from Power AutomateYesLimited
API FriendlyExcellentNo
On-demand ExecutionPerfectNo
Future ReadyYesDeprecated

When to Use Actions

  1. Manual approval

  2. Command bar buttons

  3. External integrations

  4. Complex reusable logic

  5. Output required

When to Use Workflows

  1. Legacy systems

  2. Auto-triggered background logic

  3. No UI or API dependency


Final Thoughts

Actions are the modern, reusable, API-first way to implement business logic in Dataverse.

If you are:

  • Using JavaScript

  • Using Power Automate

  • Building enterprise-grade apps

Actions should be your first choice.