Trigger a cloud flow on a button click in Dynamics 365


3 min read

How do I trigger a logic that is common across the entities contained in a cloud flow on a button click?

A few common ways:

  • Having a HTTPS trigger flow

  • Creating a 'Trigger' field on the entities

Potential drawbacks:

Having a HTTPS trigger would mean we need to also secure it, adding a trigger field on the entity is also a good option but we may end up creating a whole lot of fields to trigger the same flow across different entities.

Proposed solution:
To use the 'When an action is performed' dataverse trigger.

Idea :

  • A custom API that is unbound
    Create a custom API, that takes the record id and any required field as input parameters. These parameters can then be passed over to the cloud flow.

  • A javascript web resource that can execute the custom API
    This javascript code would execute the custom API on clicking a custom button that will then trigger the cloud flow.

  • A child flow that has a common logic that can be used across

    Having the commonly used logic inside a cloud flow helps in reusability.

    All the above components can be reused and do not require to be re-created.

Note : There is also a possibility that the entire logic in the child flow could be moved to custom api itself, but there could be many such child flows, that would mean a developer write the code and unit test it and also involves significant development efforts.The idea is to make use of low code solution that could use to trigger the logic in various child flows

Below are some of the screen grabs that could help design a solution based on the proposed idea.

Here is how the custom API looks

For the code to execute, customize the ribbon using the ribbon workbench, add a button then create a new command and add the script and pass the parameter
Crm Parameter = PrimaryControl

Sample javascript code in the web resource would look like below.

function executeCalculateWorkingDays(primaryControl) {
    var recordId =[{}]/g, "");

    var execute_sh_calculateworkingdays_Request = {
        // Parameters
        EntityId: recordId, // Edm.Guid

        getMetadata: function () {
            return {
                boundParameter: null,
                parameterTypes: {
                    EntityId: { typeName: "Edm.Guid", structuralProperty: 1 }
                operationType: 0,
                operationName: "sh_calculateworkingdays"
        .then(function success(response) {
            if (response.ok) {
        .catch(function (error) {

Here is how the child flow can be called as a step in the main flow

In short, the idea is to have a solution that can be reused across the entities without having to customize or change the logic. This would just need a developer to add a ribbon button on the required entity and add the web resource and pass the correct parameters.