In Microsoft Flow, generally there are only 5 main Action tiles for us:

  • List records
  • Get a record
  • Create a record
  • Update a record
  • Delete a record

But in some of scenario, we may want to perform action on entity, such as "qualifyLead". Currently, there is a OOB way for us to achieve it:
see this Article.

However, it seems that this Action tile will be only triggered based on condition, if we want to run flow likes an on-demand workflow, it's still required to create a http request with HTTP action to get access token from CRM, then send another HTTP request to perform action, the process is similar to what we do in Postman test.(based on Web API)

This example will call QualifyLead action to qualify a specific lead.

Step 1: Add a http action:

Step 2: Overview of configuration on the action:


Method: POST
URI: https://login.microsoftonline.com/${tenantID}/oauth2/token
Headers: Content-Type: application/x-www-form-urlencoded
Body:

grant_type=password&
client_id={clientID}&
username={adminMailbox}&
password={pwd}&
resource={organizationURL}

clientID and tenantID are available in your Azure Active Directory application

Step 3: Create a variable to save access token from http request, which will helps us to send aother http request to perform action on entity.


In the Value field, paste following dynamic expression into it.

@body('Get_access_token_from_D365')['access_token']

Get_access_token_from_D365 is my http request name, you should change it to your owns.

Then you'll get token in custom variable for next step. 😀

Step 4: Add a new http request action.


Method: POST
URI: https://{organizationURL}/api/data/v9.1/leads({leadID})/Microsoft.Dynamics.CRM.QualifyLead
Headers:
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
Authorization: Bearer {accessToken}
Body:

{
  "CreateAccount": false,
  "CreateContact": true,
  "CreateOpportunity": false,
  "Status": 3
}

It will only creates a contact record from the lead, and set the lead status to "Qualified". See statuscode field in Lead entity.

Step 5: We'll see new contact record guid from callback data.