Manually Map a Contact in Power Automate

Sending
User Review
0 (0 votes)

Introduction:

Service Provider companies manage cases to provide support or service to customers with resolution to the incident reported by the customer. With the help of automatic record creation and update rules, external source data can be captured to create Dataverse records which help to reduce manual efforts and improve the efficiency of service. For example, with incoming emails, a case record can be created automatically. This is very helpful when the team receives emails on large scale. To know more about automatic record creation and update rule, please refer this link.

Sometimes, it happens that Service Team may receive the emails from an unknown sender or from the sender who belongs to the Company (i.e. Account) present in the Dataverse but the sender (Contact) is not present in CRM. This situation can be managed by Service Team in two ways, either by creating contact automatically for the unknown sender or by mapping a contact in Power Automate.

Here, we will go through three cases and see how to map a contact manually in Power Automate.

  1. Mapping a primary contact of the same domain if the email is received from an unknown sender.
  2. Mapping a specified contact for an unknown sender.
  3. Mapping a contact for known sender i.e. existing customers.

How to map a contact manually in Power Automate:

Before proceeding to Power Automate, make sure you have set ‘Manage unknown senders by’ as ‘Mapping in Power Automate manually’. If not, kindly follow the below steps.

  • Navigate to Customer Service App -> Go to ‘Automatic record creation and update rule’ from service management area -> Open the rule on which you want to configure the setting.

map a contact in Power Automate

  • Go to Advanced tab -> In the Before evaluating conditions area, set Allow emails from unknown senders to Yes -> Then select Mapping in Power Automate manually in Manage unknown senders by.

map a contact in Power Automate

  • Click on Save and then Activate the rule.

Mapping in Power Automate manually means that you are creating mapping in Power Automate for the customer field. Basically, whenever any email is received from unknown sender, it will be mapped to the specified customer. Mapping can be created for either contact or account but not for both at the same time. If both account and contacts are mapped in Power Automate flow, it prefers to map to contact.

To map a contact in Power Automate manually, follow the steps given below:

Case I : Mapping a primary contact of same domain if the email is received from an unknown sender.

Let’s say the Service Team receives an email from a sender that is not present in the Dataverse but there is another contact present with same domain as of the sender in Dataverse. In this scenario, it can be mapped to the other contact having same domain as the sender.

  • Navigate to Customer Service App -> Switch to Service Management Area -> ‘Automatic record creation and update rule’.
  • Select and open the rule which you wish to configure -> Under Basic tab, scroll down to the region Step two: condition to evaluate and actions to take -> Select the rule item for which you want to map a contact in Power Automate manually.

map a contact in Power Automate

  • In selected rule item page, on the Condition buildertab, select Save and open Power Automate. In a new tab, Power Automate workflow will open. According to the action you have set in the Record to create, Power Automate creates a flow in which you can add more actions or edit existing actions.

map a contact in Power Automate

  1. Select Continue.

map a contact in Power Automate

2. If the connection is not created, please sign in to create a connection and select Continue.

map a contact in Power Automate

3. After selecting Continue, you will see default created Power Automate flow.

map a contact in Power Automate

The first step ‘When the incoming activity triggers the flow’ is a pre-defined trigger. It comes under ‘Microsoft Dataverse’ connector as ‘When a row is added, modified or deleted’. Here, it is renamed as ‘When the incoming activity triggers the flow’.

map a contact in Power Automate

Whenever ‘importsequencenumber’ field of ‘Email’ table is modified, this flow will get triggered.

Second Step, ‘Identify email sender’ is an ‘Initialize variable’ action that comes under ‘Variable’ connector. In this step, variable is defined to identify the type of customer. Hence, in ‘Value’ field, dynamic content ‘From’ is selected which is an output of previous step i.e. ‘When the incoming activity triggers the flow’. In this step, email id of the sender will get stored.

map a contact in Power Automate

4. Add step ‘Search Row’ action of ‘Microsoft Dataverse’ Connector. This action allows you to search a Microsoft Dataverse environment using Relevance Search, and returns the rows that match the search term. We will use this action to search contact that is to be mapping in case an email is received from an unknown sender by providing email id. To add this step, hover to the arrow after Identify email sender step and click on map a contact in Power Automatesign. Select Add an action.

map a contact in Power Automate

Under ‘Microsoft Dataverse’ connector, select ‘Search rows’ action.

map a contact in Power Automate

              To rename this step, click on the ellipsis and select ‘Rename’.

map a contact in Power Automate

Enter the email id of contact in a ‘Search term’. Enter the table unique name that is to be searched.

map a contact in Power Automate

5. Define variables to store the domain of sender and contact. Contact will be used for mapping the unknown sender. Domain will be used to find the existing contact with the same domain as of unknown sender. Under ‘Choose an operation’, enter Variable in the search bar, and you will get various variable actions. Choose Initialize variable.

map a contact in Power Automate

Rename the step. Enter name, select type as String. Set value i.e. contact id by dynamic content which will be used to map if another contact with the same domain is not found in CRM. We will see in Case II how we can use the contact id stored in this variable to map the new case record.

Under ‘Expression’ tab, enter the expression as,

outputs(‘Search_contact_to_be_mapped_(for_unknown_sender)_by_email_id’)?[‘body/value’][0][‘@search.objectid’]

It will set the contact id of 1st searched record from the output of the previous step i.e. Search contact to be mapped (for unknown sender) by email id.

map a contact in Power Automate

map a contact in Power Automate

6. Define another variable to store the contact id of the same domain as the unknown sender. Initially, set the value of ‘contactid’ variable in it i.e. ‘contactid2’ using dynamic content.

map a contact in Power Automate

7. Define the variable ‘domain’ same as above. Set the value by dynamic content. To extract domain from sender, under Expression tab, enter the expression as ‘last(split(variables(‘Customer from email sender’),’@’))’.

This expression will get the domain from email id of sender. Click OK button.

map a contact in Power Automate

8. Copy the steps ‘Create a record (don’t rename this step)’ and ‘Connect the record to the incoming activity (don’t edit or delete this step)’ to the clipboard which we will use later.

map a contact in Power Automate

The step ‘Create a record (don’t rename this step)’ is an ‘Add new row’ action of ‘Microsoft Dataverse’ connector. This will be used to create a case. In this step, we will map the contact as well.

map a contact in Power Automate

Step ‘Connect the record to the incoming activity (don’t edit or delete this step)’ is a ‘Perform an unbound action’ of ‘Microsoft Dataverse’ connector. It will be used to set regarding in email activity with the new case record.

map a contact in Power Automate

When steps are copied successfully, delete these steps.

map a contact in Power Automate

9. The step ‘Is this email sender a contact or an account’ is a Condition Control that identifies which block of actions is to be executed based on the evaluation of condition input. It evaluates the type of sender if it is a contact or account.

In the Is this email sender a contact or an account step, for the If no block, delete the step Terminate when no valid customer found as shown below:

map a contact in Power Automate

 Select Delete. On confirmation Dialog, select OK.

map a contact in Power Automate       map a contact in Power Automate

This step helps us in identifying if the email received is from an unknown sender or a known sender. So if a record either Account or Contact is found in CRM then it is from a known sender or else it is from an unknown sender.

10. Under If No, Select ‘Add an action ‘.

map a contact in Power Automate

Select Microsoft Dataverse connector.

map a contact in Power Automate

Select ‘List rows’ action.

map a contact in Power Automate

11. Rename the step. Select table name as Contacts. Click on ‘Show advanced options’.

map a contact in Power Automate

Enter Fetch XML Query, which will find primary contacts with the same domain as the sender.

map a contact in Power Automate

As shown in the above screenshot, the variable domain is set from dynamic content which helps in matching the domain for the existing contacts.

12. After this, add an action to set variable. Select variable from name dropdown.

map a contact in Power Automate

Rename step. Set value from dynamic content. Under ‘Find contacts with same domain as sender’, select Contact which will store contact id in the variable.

map a contact in Power Automate

map a contact in Power Automate

 As we have set the value as Contact of list row ‘Find contacts with same domain as sender’, ‘Apply to each’ control is set automatically on ‘Set contact’ action.

13. Add a step to add condition control.

map a contact in Power Automate

Set condition to check if the value of contactid2 is same as contactid variable value or changed with the same domain as sender.

map a contact in Power Automate

14. Under If Yes section, click Add an action. Go to My clipboard, the steps which were copied before (refer to step vi) are displayed. Select ‘Create a record (don’t rename this step)’ step. Copied step will get added.

map a contact in Power Automate

map a contact in Power Automate

15. Now open the step ‘Create a record (don’t rename this step)2’. Before specifying the required value in the Customer (Contacts), make sure that you remove the default mappings from Customer (Accounts), Customer (Contacts) and Contact (Contacts).

map a contact in Power Automate

map a contact in Power Automate

15. Specify the required value in the Customer (Contacts)field i.e. contactid2 using dynamic content. You can rename the step as well.

map a contact in Power Automate

Add another copied step i.e. ‘Connect the record to the incoming activity (don’t edit or delete this step)’.  Delete PrimaryEntityReference value. Set expression from dynamic content as, outputs (‘Create_a_case_record_for_found_contact’)?[‘body/@odata.editLink’]

Note: Make sure in outputs, ‘step name’ should be the same as the previous step.

map a contact in Power Automate

map a contact in Power Automate

map a contact in Power Automate

16. Save the Power Automate flow.

map a contact in Power Automate

Note: You can map an account but you should first remove the default mappings from the Customer (Accounts), Customer (Contacts), and Contact (Contacts) boxes and specify only an account in the Customer (Accounts).

So now whenever any new email is received from an unknown sender, email activity will get created by tracking email in Microsoft Dynamics 365 CRM. Power Automate flow will get triggered and it will set the email id in ‘Customer for email sender’.  Contact will get searched by provided email id and its contact id will be set in variable ‘contactid’ and value of ‘contactid’ in ‘contactid2’. Domain will be stored in ‘domain’ variable by using split() function on ‘Customer for email sender’ variable value.  Thereafter, it will check the sender type, whether it is a contact or account. It will then execute ‘If No’ block if the sender type is neither contact nor account.

In ‘If No’ block, it will search for another contact with same domain using fetch XML query. If any contact with same domain of sender exists in the Dataverse, its contact id will be updated in the ‘contactid2’ variable or else contactid2 variable won’t get updated.

Now, it will check that the contactid2 variable is not a match with contactid variable. If this condition satisfies, it will create a case with mapping the contact of the same domain using contactid2 and on email activity, this case will be set as regarding.

For example, let’s say we have received an email from Vin D who is not present in the Dataverse but his colleague Tiana is present in the Dataverse as a contact. In this case, it will map the contact Tiana as both belong to Company TK Pvt Ltd (i.e. Account).

map a contact in Power Automate

In the below screenshot, we can see that the contact Tiana K is set on the new case record ‘Required Service for Mobile Support.

map a contact in Power Automate

In Email Activity, regarding is set with new case record ‘Required Service for Mobile Support’.

map a contact in Power Automate

map a contact in Power Automate

Case II: Mapping a specified contact for an unknown sender

In Case I, we have seen mapping another contact with same domain if an email is received from an unknown sender. But, what if we don’t find another contact matching the same domain?  To overcome this, we will set a particular contact to map the email received from an unknown sender.

  • In the same Power Automate flow, for If No block of ‘Is contact with same domain as sender’ step, configure the steps by following the step xii to xv as explained in Case I.
  • Only the field that needs to be updated is Customer (Contacts). Use the contactid variable to map for unknown senders.

map a contact in Power Automate

  • Save the workflow.

So now whenever any new email is received from an unknown sender, email activity will get created by tracking email in Microsoft Dynamics 365 CRM. Power Automate flow will get triggered and it will set the email id in ‘Customer for email sender’.  Contact will get searched by provided email id and its contact id will be set in variable ‘contactid’ and value of ‘contactid’ in ‘contactid2’. Domain will be stored in ‘domain’ variable by using split() function on ‘Customer for email sender’ variable value.  Thereafter, it will check the sender type, if it is a contact or account. It will then execute ‘If No’ block if sender type is neither contact nor account.

In ‘If No’ block, it will search for another contact with the same domain using fetch XML query. If any contact with the same domain of sender does not exist in the Dataverse, contactid2 variable will remain as it is. It won’t get updated.

Now, it will check the value of contactid2 variable should not be the same as contactid. If the value of both variables are the same, it will create a case by mapping the contact of id defined in the contactid variable and on email activity, this case will be set as regarding.

For example, let’s say we have an email from the unknown sender ‘Dale Philip’. There isn’t any contact having the same domain as of Dale. In this case, it will map to the user Niel George as the record id of Niel has been used to set in Customer (contact).

map a contact in Power Automate

In the below screenshot, we can see that the contact Niel George is set on the new case record ‘Required Samsung M31 Mobile Support.

map a contact in Power Automate

In Email Activity, regarding is set with new case record ‘Required Samsung M31 Mobile Support’.

map a contact in Power Automate

map a contact in Power Automate

Case III: Mapping a contact for a known sender.  

We have seen how contacts get mapped for unknown senders in the above cases. Now let’s see about the known sender.

To map a contact for a known sender for which a record is already available in the CRM, follow the steps given below:

In the existing Power automate flow, navigate to step vii explained in Case I i.e. Is email sender a contact or an account. Go to the ‘If Yes’ block of Is email sender a contact or an account.

map a contact in Power Automate

The step ‘Is email sender a contact’ is a Condition Control which identifies which block of actions to execute based on the evaluation of condition input. It evaluates type of sender whether it is contact or not.

Follow similar steps from xii to xv for If yes and If no blocks of ‘Is email sender a contact’ from  Case I.

map a contact in Power Automate

If Yes block :

  • The step ‘Retrieve sender contact’ retrieves the contact from contacts with the help of contact id.

map a contact in Power Automate

  • Rename the step Set parent customer of sender as customer to Set contact as customer. Remove the value of Value field.

map a contact in Power Automate

  • Set Value from Dynamic Content. Select contact under Retrieve Sender Contact.

map a contact in Power Automate

map a contact in Power Automate

  • In a record for existing contact step, Set Customer (Contact). Type “contacts()”. In bracket, set variable ‘Customer from email sender‘ from dynamic content.

map a contact in Power Automate

  • Save the workflow.

If No section :

  • In Set account as customer, clear value of the Value And set new value to Sender(value) from dynamic content.

map a contact in Power Automate

  • In a record for existing account step, Set Customer (Account). Type “accounts()”. In bracket, set variable ‘Customer from email sender‘ from dynamic content.

map a contact in Power Automate

  • Save the workflow.

So now whenever any new email is received from a known sender, email activity will get created by tracking email in Microsoft Dynamics 365 CRM. Power Automate flow will get triggered and it will set email id in ‘Customer for email sender’.  Contact will get searched by provided email id and its contact id will be set in variable ‘contactid’ and value of ‘contactid’ in ‘contactid2’. Domain will be stored in ‘domain’ variable by using split() function on ‘Customer for email sender’ variable value.  Thereafter, it will check the sender type, if it is a contact or account. It will execute ‘If Yes’ block if sender type is either a contact or account.

In ‘If Yes’ block, it will check again with another condition that if it is of type contact or not. If Yes, it will create case with mapping the contact of id defined in a ‘Customer from email id’ variable and on email activity, this case will be set as regarding. Otherwise, it will create case by mapping the account of id defined in a ‘Customer from email id’ variable and on email activity, this case will be set as regarding.

For example, lets say we have an email from a known sender ‘Elma Smith’. There is a contact record for Elma Smith in a Dataverse. In this case, it will map to the contact itself i.e Elma Smith.

map a contact in Power Automate

In the below screenshot, we can see that the contact Elma Smith is set on the new case record

Need Mobile Support.

map a contact in Power Automate

In Email Activity, regarding is set with new case record ‘Need Mobile Support’.

map a contact in Power Automate

map a contact in Power Automate

Conclusion:

In this way, the customer service team can easily map a contact for known/unknown senders by using Power Automate flow for the rules that are created for creating or updating case records automatically.

Kanban Board