Tutorial 6 - Adding a custom action button to insight card to invoke custom action (CRM Process)

Completed

A capability to add custom-defined actions to insight cards is introduced and is currently available in preview.

Capability to add custom-defined actions to insight cards preview.

New button types are introduced to Create card for assistant V2 operation.

Create card for assistant V2 has a Custom action (CRM process) button type.

Examples use case

We will create an insight card that will be displayed when an opportunity estimated closing date is within a day and we will add an action to extend estimated closing date by 10 days.

Test Data

Create one or more opportunities where the estimated closing date is current date.

Step 1: Create a trigger to start the flow 

Set a trigger that runs every morning at 8 am. 

  1. In the search, enter Recurrence. From the search results, under the Triggers option, select Recurrence.

    Recurrence search results show Recurrence Schedule on the Triggers tab.

  2. You'll see the below trigger. Enter Interval as 1 and select Frequency as Day. This ensures that the trigger will run once in day. 

    The other columns can be set according to your requirement. In this example, we are setting At these hours as 8, as we want the trigger to run every morning at 8 AM. 

    The At these hours property is set to 8.

Step 2: Get all opportunities which are closing today.

  1. Select New Step and in the search box, enter Microsoft Dataverse and choose List Records.

    Enter Microsoft Dataverse and choose List Records.

  2. Add a filter query to retrieve all opportunities closing today.

    estimatedclosedate eq @{formatDateTime(utcNow(), 'yyyy-MM-dd')}

    Add a filter query to retrieve all opportunities closing today.

Step 3: For every opportunity create the custom insight card.

For all opportunities fetched from previous step, we will use new operation Create card for assistant V2 and create an insight card.

  1. Click New Step below List records action and add Apply to each action.

    Under List records, in Choose an action, search  results for apply to each appear on the Actions tab.

  2. Select all opportunities from Dynamic content for iteration.

    On Apply to each, select Add dynamic content and choose value List of items.

  3. In Apply to each operation, select Add an action and search for Sales Insight. You will see sales insight action as shown in introduction section, choose Create card for assistant V2 operation.

    Apply to each contains value from previous steps, and Create card for assistant V2.

  4. Enter the environment.

    On Create card for assistant V2, the environment is set to TestOrg, and other required columns are filled.

You can observe that Extend Close Date is used as button text.

We will make Extend Close Date to extend the estimated close date of related opportunity using REST and custom action.

3.1 Action using Custom Action

We will now invoke a custom action in CRM, which will change estimated closing date.

3.1.1 Create a custom action inside CRM to extend estimated close date

To create a custom action, go to Settings > Processes > New.

  1. Enter the name as ExtendClosingDate, and select Category as Action and table as Opportunity.

    Enter the name as ExtendClosingDate, and select Category as Action and table as Opportunity.

  2. From Add Step, select Update Record.

    The Add Step menu has Update Record selected.

    Update is set to Opportunity, and there is a Set Properties button.

  3. Select Set Properties and then configure Est. Close Date as 10 days after current Est. Close Date.

    Configure Est. Close Date as 10 days after current Est. Close Date.

  4. Select Save and Close and then activate the custom action to be discovered by our operation.

3.1.2 Invoking custom action from an insight card with opportunity as target

In Apply to each action, select Add an action.

Select Add an action below Create card for assistant V2.

  1. Search for Sales insight and select Choose custom action (CRM process) for an insight card.

    Select Choose custom action (CRM process) for an insight card.

  2. Select the environment, and then select Filter by table as Opportunities and Custom action (CRM process) as ExtendedClosingDate.

    Set Filter by table to Opportunities and Custom action (CRM process) to ExtendedClosingDate.

    Enter the opportunity ID in the Target box. Use the opportunity ID that is used in the previous step from Dynamic content.

    Enter the opportunity ID in the Target box.

    After the selection you'll see the operation as below.

    Completed operation with Target set to Opportunity.

  3. Add Create card for assistant V2 step below as we did for REST.

    Add Create card for assistant V2 below Choose custom action (CRM process) for insight card.

  4. Select Button type as Custom action (CRM Process). You'll see a new column Custom action for insight card column.

  5. Select Custom action for insight card from dynamic content popup. This is a custom action we chose in previous step.

    Select Custom action for insight card from Dynamic content.

You're ready to run the card and configuration looks like below.

Completed card with all required columns filled.

Step 4: Save the flow

Step 5: Test the flow

When the flow runs as scheduled or you run it manually, you should have a card created and displayed on dashboard as shown below.

Tutorial card as it is displayed on the dashboard.

We have our defined action available as the button on sales insights card.

Click on Extend Close Date. The opportunity will be updated with the new estimated close date and a confirmation message is displayed.

Message reads: Successfully invoked extend close date.

We extended the opportunity's estimated closing date with new action using CRM process.