---
title: "How to Create Dataverse Activities using Power Automate"
excerpt: "In this Power Platform tutorial, you will set up an HTTP webhook using the \"When an HTTP request is received\" action. With the HTTP request JSON, you will calculate the duration between two timestamps and fetch a contact and user by finding matching phone numbers. Then, you will create a phone call and update the status of the phone call."
publishDate: "2021-09-22T00:00:00"
createDate: "2021-09-22T19:37:41.463"
updateDate: "2021-09-22T20:05:23.477"
category: "dynamics"
categoryName: "Dynamics"
tags: ["Dynamics","Dynamics CRM","Dynamics 365","Power Apps","Power Platform","Dataverse","Microsoft"]
permalink: "/blog/dynamics/how-to-create-dataverse-activities-using-power-automate"
canonical: "https://blog.metrostar.com/dataverse-activities-using-power-automate"
image: {"src":"/media/noklogam/metrostar_howto-blog_dataverseactivities-01.jpg","focalPoint":{"left":0.5,"top":0.5},"crops":[{"alias":"Banner","width":1120,"height":400,"coordinates":null}]}
imageAlt: "How to Create Dataverse Activities using Power Automate"
imageBackgroundColor: "#474fe2"
thumbnailImage: {"src":"/media/h5xlm5oh/social-share-post-ignite.png","focalPoint":{"left":0.5,"top":0.5},"crops":[{"alias":"thumbnail","width":250,"height":250,"coordinates":null}]}
thumbnailImageAlt: "Power Apps logo"
metaTitle: "How to Create Dataverse Activities using Power Automate"
metaDescription: "Learn how to use Power Automate to create Dataverse activities using a webhook trigger."
ogTitle: "How to Create Dataverse Activities using Power Automate"
ogDescription: "Learn how to use Power Automate to create Dataverse activities using a webhook trigger."
ogImage: {"src":"/media/p25ak5zt/metrostar_howto-blog_dataverseactivities-01.jpg","focalPoint":{"left":0.5,"top":0.5},"crops":[{"alias":"OpenGraph","width":1200,"height":630,"coordinates":null}]}
ogImageAlt: "How to Create Dataverse Activities using Power Automate"
relatedPostKeys: ["2dc3a433eb6848c89e2acb79cc3dcf32","977085c5703b4b2dbbc529832cbc0f8c","fb25448203074afb9d3afb16e725df8b","20863c150f73425db7daf7424300d9f0"]
noIndex: false
noFollow: false
sitemapExclude: true
source: {"nodeId":1568,"contentKey":"7db1bd89f2a544deabdce7ad940fbfb7","sortOrder":109}
---


**This blog post was written for [MetroStar Systems](https://metrostar.com) and originally published at [MetroStar's blog here](https://blog.metrostar.com/dataverse-activities-using-power-automate).**





Dataverse (formerly known as Common Data Service) and Dynamics CRM come with many activities out of the box. For example, after a customer representative has a phone call with a customer, the representative can create a <a rel="noopener" href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/reference/entities/phonecall" target="_blank">phone call activity</a> on the customer's contact record to keep track of that particular call.





Out of the box, Dataverse comes with the following <a rel="noopener" href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/activity-entities" target="_blank">activities</a>:





-   Phone Calls
-   E-Mails
-   Letters
-   Appointments
-   Fax
-   Notes


Apart from E-Mails, these activities don't have special behaviors associated with them. Activities simply allow you to manually record interactions; however, with email, you can automatically record messages and send emails from your CRM.

Don’t worry about manually recording these interactions. You can automate this process with Power Automate!

## Create Built-In Activities using Power Automate {#create-built-in-activities-using-power-automate}




Let's say that you are integrating with a fictitious telephony vendor, *TeleAPI*. TeleAPI will notify you whenever a phone call has concluded by sending an HTTP request to your webhook. These requests are a common functionality provided by many real-life phone and SMS vendors.




## Setup an HTTP Webhook Trigger {#setup-an-http-webhook-trigger}

To receive an HTTP request, create a new Power Automate Cloud Flow and use the trigger called, "When an HTTP request is received." Once you save this flow, the trigger will generate the URL for you to configure as your webhook.

Click on the link *Use sample payload* to generate schema on the trigger and paste in the following sample JSON:

<pre style="color:#000000;background:#ffffff;"><span style="color:#800080; ">{</span>&#10;    <span style="color:#800000; ">"</span><span style="color:#0000e6; ">from</span><span style="color:#800000; ">"</span><span style="color:#800080; ">:</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">+11234567890</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span>&#10;    <span style="color:#800000; ">"</span><span style="color:#0000e6; ">to</span><span style="color:#800000; ">"</span><span style="color:#800080; ">:</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">+11234567890</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span>&#10;    <span style="color:#800000; ">"</span><span style="color:#0000e6; ">direction</span><span style="color:#800000; ">"</span><span style="color:#800080; ">:</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">in</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span>&#10;    <span style="color:#800000; ">"</span><span style="color:#0000e6; ">startedAt</span><span style="color:#800000; ">"</span><span style="color:#800080; ">:</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">2021-08-04T12:00:00.000Z</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span>&#10;    <span style="color:#800000; ">"</span><span style="color:#0000e6; ">endedAt</span><span style="color:#800000; ">"</span><span style="color:#800080; ">:</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">2021-08-04T12:30:00.000Z</span><span style="color:#800000; ">"</span><span style="color:#808030; ">,</span>&#10;    <span style="color:#800000; ">"</span><span style="color:#0000e6; ">transcript</span><span style="color:#800000; ">"</span><span style="color:#800080; ">:</span> <span style="color:#800000; ">"</span><span style="color:#0000e6; ">Caller 1: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Caller 2: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Caller 1: Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Caller 2: Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</span><span style="color:#800000; ">"</span>&#10;<span style="color:#800080; ">}</span>&#10;</pre>



<p><img loading="lazy" src="https://lh5.googleusercontent.com/F7wjxpZ7ItRh5x0zarDI6uqVsunMjb2Lu4t2hBmfENKJ5ecsZFUN0iUM5V8AiS3ZAcwpa2la9lLyhKBdfhP59hIJu1Pk-iwY7SWX5EZ1PBlLnHN7nsy4dV0AyFFBBOUnw61THepR=s0" alt="JSON payload code" width="624" height="436"></p>

This is the JSON that the fictitious TeleAPI vendor will submit to your HTTP webhook. It has the following properties:


-   **from**: the phone number that initiated the call
-   **to**: the phone number that was called by the initiator
-   **direction**: who initiated the phone call
    -   "**in**" means the call was initiated by the customer and went towards your company
    -   "**out**" means the call was initiated by someone from your company and went towards your customer
-   **startedAt**: date and time stamp of when the phone call started
-   **endedAt**: date and time stamp of when the phone call ended
-   **transcript**: a transcript provided of the conversation


This JSON sample is fictitious for the sake of the tutorial, but these are the common data points from telephony vendors out there. After pasting in the above JSON, click on the *Done* button. Power Automate will generate a JSON schema for you and make all JSON properties accessible. Click on *advanced options* and change the *method* dropdown to POST.

Hit *Save* and take note of the HTTP POST URL for later.

<p><img loading="lazy" src="https://lh3.googleusercontent.com/JIYhY9wJPcqGv-zPbs2gkIJYHs0poxL08B22IfIMSfPiuByN6YSSqK4yGhLo78WUkaHthH7iwRhdd6XKR8Gnx2UWU3DskdnzvBhUej5Bxi6PZoF7OpgwHTmOASncrJGGN0g2iP8y=s0" alt="shows form for when a HTTP request is received " width="624" height="487"></p>



## Calculate the Duration of the Call {#calculate-the-duration-of-the-call}



<p>The phone call activity has many columns you can populate. To fill out the duration column, you'll need to calculate the duration between <em>startedAt</em> and <em>endedAt</em>. Duration columns in Dataverse are stored as integers where one integer equals "1" minute.</p>



<p>To calculate the duration in minutes, you'll add <em>two Initialize variable actions</em>. The first action will convert the <em>endedAt</em> to ticks, the <em>startedAt </em>to tick, and subtract the <em>startedAt</em> ticks from the <em>endedAt</em> ticks. This action will give you the duration in ticks.</p>

Here's a formula to accomplish this:

<pre style="color:#000000;background:#ffffff;">sub<span style="color:#808030; ">(</span>ticks<span style="color:#808030; ">(</span>triggerBody<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">endedAt</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span>ticks<span style="color:#808030; ">(</span>triggerBody<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">startedAt</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">)</span><span style="color:#808030; ">)</span>&#10;</pre>




Use this formula to initialize the *durationInTicks* variable with *Type Integer*. Next, create another *Initialize variable* action to convert the ticks to minutes.


You can use the following formula to accomplish this:

<pre style="color:#000000;background:#ffffff;">div<span style="color:#808030; ">(</span>div<span style="color:#808030; ">(</span>mul<span style="color:#808030; ">(</span>variables<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">durationInTicks</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span><span style="color:#008c00; ">100</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span><span style="color:#008c00; ">1000000000</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span><span style="color:#008c00; ">60</span><span style="color:#808030; ">)</span>&#10;</pre>




Use this formula to initialize the *durationInMinutes* variable with *Type Integer*. You could merge both calculations into a single formula, but for the sake of readability and maintainability, break them into two steps.


The image below shows what the result should look like at this stage:

<p><img loading="lazy" src="https://lh4.googleusercontent.com/GaOkLSwp3zzgYCWYMMmt1SLzq7Mc_HLogeX99FHP8YQqcFyCAgcwhxsSOZ6sL3SnblG9D97AapjPAo2UGTpvVf56m_rlcBhQD74iZG3-I3OUT4H6hHTU92mGtnWsdwYaRMF8C_tu=s0" alt="shows durationinminutes and duratiointicks forms in Dataverse. " width="624" height="501"></p>



### Fetch the Dataverse Contact End-User {#fetch-the-dataverse-contact-end-user}

You want to fill out who made the call and who received the call. To do this you'll need to find the contact (customer) and the user (representative).

If it's an incoming call, you'll need to fetch the CRM user with a phone number that matches the *to* property. If it's an outgoing call, then you'll need to fetch the CRM user with a phone number that matches the *from* property.

<p>Additionally, if it's an incoming call, you'll need to fetch the contact with a phone number that matches the <em>'</em><em>from </em>property. If it's an outgoing call, you'll need to fetch the contact with a phone number that matches the <em>to</em> property.</p>



<p>To fetch the CRM user, add a new Dataverse action called <em>List rows</em> and select <em>Users</em> as the table name. Click on <em>Show advanced options </em>and fill out the <em>Filter rows</em> property as follows:</p>



<pre style="color:#000000;background:#ffffff;">mobilephone eq <span style="color:#800000; ">'</span><span style="color:#0000e6; ">@{if(equals(triggerBody()?[</span><span style="color:#800000; ">'</span>direction<span style="color:#800000; ">'</span><span style="color:#0000e6; ">], </span><span style="color:#800000; ">'</span>in<span style="color:#800000; ">'</span><span style="color:#0000e6; ">), triggerBody()?[</span><span style="color:#800000; ">'</span>to<span style="color:#800000; ">'</span><span style="color:#0000e6; ">],triggerBody()?[</span><span style="color:#800000; ">'</span>from<span style="color:#800000; ">'</span><span style="color:#0000e6; ">])}</span><span style="color:#800000; ">'</span>&#10;</pre>

Depending on whether the phone call is incoming or outgoing, the *to* or *from* property will be used to filter the users with a matching *mobilephone* property. The result of this query could be 0, 1, or multiple rows, but to keep things simple this tutorial will assume the results always return to 1. To make the flow more production-ready, you should add additional complexity to handle the other scenarios.

Rename the list rows action to list users.

<p>Add another<em> In</em><em>itialize variable</em> action with <em>Name</em> "user" and <em>Type</em> "Object". Use the following expression for the Value property:</p>



<pre style="color:#000000;background:#ffffff;">first<span style="color:#808030; ">(</span>outputs<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">List_Users</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">body/value</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">)</span>&#10;</pre>



<p><img loading="lazy" src="https://lh5.googleusercontent.com/8i-KD2IPmmVEOaMHEyFgg5jmHyrJL5iYg-XEleRNXTvZ-D1xwfLd9LXVximvcfa7xFeUPVfUqsQzOQcBi6zV_mWHaOY3RDvH40xrgp-hxQZ_AGlcmYf7392F-q4oJrSebQ3ktdMK=s0" alt="list users form in Power Automate" width="624" height="663"></p>



<p>Now you will repeat the same logic to fetch the contact. Add the new Dataverse action <em>List rows</em> and select <em>Contacts</em> as the <em>Table name</em>. Click on <em>Show advanced options </em>and fill out the <em>Filter rows </em>property as follows:</p>



<pre style="color:#000000;background:#ffffff;">mobilephone eq <span style="color:#800000; ">'</span><span style="color:#0000e6; ">@{if(equals(triggerBody()?[</span><span style="color:#800000; ">'</span>direction<span style="color:#800000; ">'</span><span style="color:#0000e6; ">], </span><span style="color:#800000; ">'</span>in<span style="color:#800000; ">'</span><span style="color:#0000e6; ">), triggerBody()?[</span><span style="color:#800000; ">'</span>from<span style="color:#800000; ">'</span><span style="color:#0000e6; ">],triggerBody()?[</span><span style="color:#800000; ">'</span>to<span style="color:#800000; ">'</span><span style="color:#0000e6; ">])}</span><span style="color:#800000; ">'</span>&#10;</pre>



<p>Note same as above: Depending on whether the phone call is incoming or outgoing, the <em>from</em> or <em>to</em> property will be used to filter the users with a matching <em>mobilephone</em> property. The result of this query could be 0, 1, or multiple rows, but to keep things simple this tutorial will assume it will always return 1. To make the flow more production-ready, you should add additional complexity to handle the other scenarios.</p>



<p>Rename the <em>List rows</em> action to <em>List Contacts</em>. Add another <em>Initialize variable </em>action with <em>Name </em>"contact" and <em>Type</em> "Object".</p>




Use the following expression for the *Value property*:




<pre style="color:#000000;background:#ffffff;">first<span style="color:#808030; ">(</span>outputs<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">List_Contacts</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">body/value</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">)</span>&#10;</pre>

Now the CRM user and contact are stored in a variable which you can use to create your phone call activity.

### Create the Phone Call Activity {#create-the-phone-call-activity}



<p>Add an <em>Add a new row </em>action and fill out the properties as listed below:</p>



<table border="0" width="1074">
<tbody>
<tr>
<td>

Property name

</td>
<td>

Property value

</td>
</tr>
<tr>
<td>

**Table name**

</td>
<td>

Phone Calls


<small>Note: This property specifies the table you want to create a new row for.</small>

</td>
</tr>
<tr>
<td>

**Subject**

</td>
<td>

Phone call between @{variables('user')\['fullname'\]} and @{variables('contact')\['fullname'\]}


<small>Note: Every activity table has a "Subject" property. Using the formula above, the "Subject" will look like "Phone call between Jon Doe and Jane Doe"</small>

</td>
</tr>
<tr>
<td>

**Description**

</td>
<td>

Transcript: @{triggerBody()?\['transcript'\]}


<small>Note: Multi-line text field to add more details about your call. The formula above will print the transcript into the description column.</small>

</td>
</tr>
<tr>
<td>

**Direction**

</td>
<td>

@equals(triggerBody()?\['direction'\], 'out')


<small>Note: Whether the phone call is inbound (False) or outbound (True)</small>

</td>
</tr>
<tr>
<td>

**Duration**

</td>
<td>

@{variables('durationInMinutes')}


<small>Note: The duration of the phone call in minutes.</small>

</td>
</tr>
<tr>
<td>

**Owner**

</td>
<td>

/systemusers(@{variables('user')\['systemuserid'\]})


<small>Note: The owner assigned to the activity. "/systemusers()" specifies to bind a row from the "systemuser" table to the property. Between the parenthesis, the GUID for the system user is inserted to specify the specific CRM user.</small>


<small><em>Example: /systemusers(640FE680-F33C-46AD-B63C-652A9783771A)</em></small>


<small>This is&nbsp;<a rel="noopener" href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/create-entity-web-api#associate-table-rows-on-create" target="_blank">how you set the value of a lookup field in Dataverse</a>&nbsp;and Dynamics CRM's API.</small>

</td>
</tr>
<tr>
<td>

**Phone Number**

</td>
<td>

@{variables('contact')\['mobilephone'\]}


<small>Note: Specify the phone number of the contact</small>

</td>
</tr>
<tr>
<td>

**Regarding (Contacts)**

</td>
<td>

/contacts(@{variables('contact')\['contactid'\]})


<small>Note: Specify which contact made or received this phone call. "/contacts()" specifies to bind a row from the "contact" table to the property. Between the parenthesis, the GUID for the contact is inserted to specify the specific CRM user.<br></small>


<small><em>Example: /contacts(990D302E-9EB6-46E6-99C3-2EE8296030D7)</em></small>


<small>This is&nbsp;<a rel="noopener" href="https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/create-entity-web-api#associate-table-rows-on-create" target="_blank">how you set the value of a lookup field in Dataverse</a>&nbsp;and Dynamics CRM's API.</small>

</td>
</tr>
</tbody>
</table>



<p><img loading="lazy" src="https://lh6.googleusercontent.com/sVoCqgDXd8RX6d6klFQ5OUPsp0ojRN8Rasfr4T-wkF8g0aBGb-piHO5jc5DnilwKpBLEDdaiKh2HQMjYtm0Bykd-PI1goeUI7t_FGLJRe3HpW81gOSJhyIT9T6z5Ou57GLrrRone=s0" alt="Create Phone Call form in Power Automate" width="624" height="639"></p>



<p>At the bottom of the action, configure the<em> Activity Party Attributes</em>. Set <em>Activity Party Attribute Name - 1</em> to "Call From."</p>

Set *Activity Party Attribute Value - 1* to the following expression:

<pre style="color:#000000;background:#ffffff;">if<span style="color:#808030; ">(</span>equals<span style="color:#808030; ">(</span>triggerBody<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">direction</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">,</span> <span style="color:#800000; ">'</span><span style="color:#0000e6; ">in</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> concat<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">/contacts(</span><span style="color:#800000; ">'</span><span style="color:#808030; ">,</span> variables<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">contact</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">contactid</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">,</span> <span style="color:#800000; ">'</span><span style="color:#0000e6; ">)</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> concat<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">/systemusers(</span><span style="color:#800000; ">'</span><span style="color:#808030; ">,</span> variables<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">user</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">systemuserid</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">,</span> <span style="color:#800000; ">'</span><span style="color:#0000e6; ">)</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">)</span>&#10;</pre>



<p>Depending on whether the call is inbound or outbound, the contact or the CRM user is bound as the call from value. Click on <em>Add new item </em>and set <em>Activity Party Attribute Name - 2</em> to "Call To."</p>



<p>Set <em>Activity Party Attribute Value - 2</em>  to the following expression: </p>
if(equals(triggerBody()?['direction'], 'in'), concat('/systemusers(', variables('user')['systemuserid'], ')'), concat('/contacts(', variables('contact')['contactid'], ')'))

Depending on whether the call is inbound or outbound, the CRM user or the contact is bound as the call to value. Click on the *Show advanced options* and fill out the following two properties:




- "Actual End": @{triggerBody()?\['endedAt'\]}
- "Actual Start": @{triggerBody()?\['startedAt'\]}

This will grab the start and end timestamps from the HTTP request and set them to the appropriate phone call column.

<p><img loading="lazy" src="https://lh3.googleusercontent.com/vA1flS9YVh1UPDyO3OiYpsau7qz2Jc9iWfPbRqY1NDhKCfyeUu-FnEe2owQW2CaletkCYRtrO1QR7shWnTjAxAV8jMPn54ZQThQSmn9bxU0N_mlS-SsSZIsXtZidjjBR73dcL7FP=s0" alt="form in Power Automate" width="624" height="553"></p>

Rename the action to "Create Phone Call." By default, the phone call status will be *Active* and this cannot be set during creation. Since the phone call has already been made, you should update the phone call entity with the correct status and status code.

Add an *Update a row* action. Set the *Table name* to "Phone Calls" and the *Row ID* to the following expression:

<pre style="color:#000000;background:#ffffff;">outputs<span style="color:#808030; ">(</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">Create_Phone_Call</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">body/activityid</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span>&#10;</pre>



<p><img loading="lazy" src="https://lh5.googleusercontent.com/yZ29HUrIHIEXzPsnqnQuH3KuUk9NFYqER1410FBrKjHv43epajCFKmNDlWGh99AVCGs13V6m0TcOXulvJpSpoN_MqF77oxe-ouJZqhb5AoJbj_esBudT1l-59Ti4b0JP7SyrIzfX=s0" alt="Update phone call form in in Power Automate" width="624" height="208"></p>




Click on *Show advanced options*. Then, set the *Activity Status* to *Completed* and the *Status Reason* to the following expression:




<pre style="color:#000000;background:#ffffff;">@if<span style="color:#808030; ">(</span>equals<span style="color:#808030; ">(</span>triggerBody<span style="color:#808030; ">(</span><span style="color:#808030; ">)</span><span style="color:#808030; ">?</span><span style="color:#808030; ">[</span><span style="color:#800000; ">'</span><span style="color:#0000e6; ">direction</span><span style="color:#800000; ">'</span><span style="color:#808030; ">]</span><span style="color:#808030; ">,</span> <span style="color:#800000; ">'</span><span style="color:#0000e6; ">in</span><span style="color:#800000; ">'</span><span style="color:#808030; ">)</span><span style="color:#808030; ">,</span> <span style="color:#008c00; ">4</span><span style="color:#808030; ">,</span> <span style="color:#008c00; ">2</span><span style="color:#808030; ">)</span>&#10;</pre>



<p>The number 4 represents the status reason <em>Received </em>and the "2" represents the status reason <em>Made</em>.</p>



<p><img loading="lazy" src="https://lh6.googleusercontent.com/ITeNEJhlmrDRheoUq8jM4eX6PZtjRO-fJGpQ0AcOHEszQ7ea4joY2AQ7bKmQY_ZMw-u7K4H-Fcf-TnIFIMKlnDz9FtFuFTONkBZeYUrA9PX9Ux2pouacGaGSKLaHn8zMS6Y8ziL-=s0" alt="form in in Power Automate" width="624" height="283"></p>




Don't forget to click *Save*.




## Testing the Flow {#testing-the-flow}

Before testing the flow, make sure you have one contact and one user with the phone number you will use to test. Open a *PowerShell shell* and use the following PowerShell commands to send the HTTP request:

<pre style="color:#000000;background:#ffffff;">$Uri = <span style="color:#2a00ff; ">"</span><span style="color:#2a00ff; ">REPLACE WITH YOUR HTTP POST URL</span><span style="color:#2a00ff; ">"</span>;&#10;$Body = <span style="color:#2a00ff; ">'</span><span style="color:#2a00ff; ">{</span>&#10;<span style="color:#2a00ff; ">&nbsp;&nbsp;&nbsp;&nbsp;"from": "+11234567890",</span>&#10;<span style="color:#2a00ff; ">&nbsp;&nbsp;&nbsp;&nbsp;"to": "+11234567890",</span>&#10;<span style="color:#2a00ff; ">&nbsp;&nbsp;&nbsp;&nbsp;"direction": "in",</span>&#10;<span style="color:#2a00ff; ">&nbsp;&nbsp;&nbsp;&nbsp;"startedAt": "2021-08-04T12:00:00.000Z",</span>&#10;<span style="color:#2a00ff; ">&nbsp;&nbsp;&nbsp;&nbsp;"endedAt": "2021-08-04T12:30:00.000Z",</span>&#10;<span style="color:#2a00ff; ">&nbsp;&nbsp;&nbsp;&nbsp;"transcript": "Caller 1: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&nbsp;Caller 2: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.&nbsp;Caller 1: Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.&nbsp;Caller 2: Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."</span>&#10;<span style="color:#2a00ff; ">}</span><span style="color:#2a00ff; ">'</span>;&#10;Invoke-WebRequest -Uri $Uri -Method <span style="color:#2a00ff; ">Post</span> -Body $Body -ContentType <span style="color:#2a00ff; ">"</span><span style="color:#2a00ff; ">application/json</span><span style="color:#2a00ff; ">"</span>;&#10;</pre>



<p>If you check out the timeline on the contact, then you should now start seeing the phone calls (an example in the image below). </p>



<p><img loading="lazy" src="https://lh6.googleusercontent.com/JC6hRbJIIAPXiyCQ8hifKuzSN840oJE0UylLYG5TTomPDDxxpTXb-yyceGCiiueFvaXeNMvk511OWAIOg4ukcUk3eC0jDyA5MMXoPaom-khWvheQnyadQJhhTbdMbR6bLUJJ1tRe=s0" alt="email example in in Power Automate" width="624" height="371"></p>



## Custom Activities with Custom Tables Enabled for Activities {#custom-activities-with-custom-tables-enabled-for-activities}

These built-in activities were introduced a long time ago, and since then, there has been an explosion of different ways to communicate with your customer. You want to be where your customers are, and they are most likely on social media, SMS, and chat services. But, there are currently no activities out-of-the-box to record these newer types of interactions.


Luckily, Dataverse allows you to create your own custom activity tables. These tables work the same way as other custom tables except you can’t specify a primary column. By default, custom activities will have a primary column called *Subject*. Although, just like other tables, you can create columns, relationships, views, forms, and more to capture the data you want to keep track of.





Additionally, you can enable activities on other tables. You can do this by going to the table settings and check *Enable for activities*. Then you can start recording activities for your own tables.





However, when creating activities for a custom table using Power Automate, you do have to change some things. First, make sure you are not using any *Activity Party Attributes*. Those attributes are only for tables that come "out-the-box" with activities enabled.





If you still try to use the *Activity Party Attributes*, then you will get an error like this: *"Relationship between activityparty and crb09\_xxx doesn't exist."*




<p>Second, find the <em>Regarding (Applications} </em>lookup field that points to your custom table and insert the lookup binding syntax there (example in the image below).</p>



<p><img loading="lazy" src="https://lh6.googleusercontent.com/qCTMb4gVdck6wTY85QTFhfBt3vcwmRe-waCm5z9RhciFAWuQ7JRT86Ivz5ttqR0z-t2vlhYOzhCsqWqCHXJlAKbYioLGDrTf4t2CUL34G7V2LBYlmv0MfG2rIVgt7TsTAryqMqmk=s0" alt="form in Power Automate" width="624" height="236"></p>



## Summary {#summary}

You can use built-in activities to log different interactions between your employees and your customers such as phone calls, E-Mails, and more. You can also automatically log some of these interactions by creating built-in activities using Power Automate Cloud Flows.
