Identify the Source of Records Created From Microsoft Portal in Dynamics 365

By | September 7, 2018

Introduction:

Microsoft Portals can be accessed by authenticated and as well as anonymous contacts. So if a user has privileges to create records in Dynamics CRM, irrespective of the fact that they are logged into the Portal or not, then when such records get created in CRM-owner of those records will be set as SYSTEM.  But if we want to know who actually created the records from Portal in CRM and from which IP address (for anonymous access), then by doing some portal configurations, we can achieve this goal. For this purpose, we need to have two fields – “Created By(Portal Contact)” and “Created By(IP Address)”. These two fields are already present as OOB fields in Contact and Account entities in CRM where portal is configured. Please note that in CRM where Custom Portal is configured(instead of Partner Portal), the field “Created By (Portal Contact)” is present as “Created By (Portal User)” in Account and Contact entities. But for other entities, we can make the above mentioned fields as custom fields for the same purpose in CRM where Partner Portal/Custom Portal is configured. The field “Created By (IP Address)” should be a single line text field and the field “Created By (Portal Contact)” should be a lookup field of contact type.

So here’s how we can know who created entity records from Portal to CRM and from where. As a demonstration purpose, I am going to use a Contact entity as an example.

Steps To Identify Which Contact In CRM Created Records From Portal To CRM

Here when a user logs into the Portal and creates an entity record, follow the following steps to identify who was that particular contact in CRM who logged into the Portal and created the entity record in CRM from the portal.

1. On the Entity Form Of Contact (or any Entity you would like to configure) used in the Web Page where the logged in person creates contact, check the option of  “Associate Current Portal User” on saving the contact record from Portal as seen and highlighted in the screenshot below. This screenshot is of an Entity form made for Contact Entity which we are considering as an example.

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

2. Now select the field – “Created By(Portal Contact)” among the list of lookup fields which is used to identify that for which field-the logged in contact(of CRM)must be set as a reference in the newly created contact record. Please see the below screenshot for the same especially the highlighted parts.

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

3. Save these two settings(mentioned in the two steps above) on the Entity form.

4. Now whenever a contact gets created from the Portal, the field “Created By (Portal Contact) will have the reference of logged in portal contact member. Please check the below screenshot of the advanced find of contacts created (post the settings we did above).

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

As seen in the screenshot above, even though the Owner of newly created contacts was set as “System”, the value in “Created By (Portal Contact)”-“Vincent Lauriant” indicates it’s the contact “Vincent Lauriant” created the new contacts by logging into the portal. The below screenshot indicates the same too that Vincent is a contact record in CRM with portal access.

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

Steps To Identify From Which IP Address Records Got Created From Portal To CRM

Here is a contact in CRM logins to the portal and creates an entity record OR when a user access Portal without logging to the portal and creates an entity record, follow the following steps to identify from which IP address does this anonymous user created the entity record in CRM from portal.

1. Add the field “Created By (IP Address)” to the form selected in the Entity Form. For example, in the Entity Form taken as an example here, we are using the form “Profile Web Form” of Contact entity. And in that, we have added the field “Created By (IP Address)” in the tab-“General” which is the tab used in the Entity form as seen in the screenshots below. Also please make sure to uncheck the option to display label name of “Created By (IP Address)” field on form as we are later going to keep the field in the background by script(Will tell the reason for it when that step comes).

Entity Form Screenshot

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

Contact Form Screenshot

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

 

Properties of “Created By IP Address” field on the form Screenshot

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

2. Save and publish the changes in the form chosen in the Entity Form, which here is “Profile Web Form” of contact entity.

3. Now on the entity form, we will put our script code in the Entity form which will retrieve IP address when the page gets loaded where the logged in portal contact will create a new contact from the portal. Please see the below screenshot where we put our script in the Entity form in the highlighted section-“Custom Javascript” of Entity Form.

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

4. Below is the code to retrieve Public IP Address which is called when the web page to create contacts gets loaded.

$(document).ready(function (){   
//read the public IP address   
$.getJSON('https://api.ipify.org?format=json', function(data){     
//set the retrieved public IP address to the text field-Created By IP Address 
//whose logical name(in our example) is adx_createdbyipaddress     
$("#adx_createdbyipaddress").val(data.ip);     
//hide the text field-Created By IP Address on the form     
$("#adx_createdbyipaddress").hide(); 
}); 
});

5. Please note that as we are setting the value to the field “Created By IP Address” in the background, the column must be kept visible in the original form(“Profile Web Form”)and after setting the value, we are hiding the field via script as user is NOT expected to enter his IP Address. If we make the field hidden in the original form(“Profile Web Form”), then the script won’t run and no IP Address would be set when the contact gets saved.

6. Here’s the screenshot of contact created from portal with his public IP addresses

Identify the Source of Records Created From Microsoft Portal in Dynamics 365

Conclusion:

Using the above steps we can find out the source of Dynamics 365 CRM records created from Microsoft Portal.

google-maps-dynamics-crm-turn-turn-gps-navigation

 

Leave a Reply

Your email address will not be published. Required fields are marked *