Have you ever tried adding a System Activity (e.g. Task, Appointment etc.) subgrid to your form? Have you noticed on launch of the create form, Regarding field is not pre-populated? This is because one of the limitations in Dynamics CRM is that System Activity entities do not support field Mapping. One workaround is to use the Social Activity Pane to create activity records to pre-populate the Regarding field. But what if you need to map more fields? This is what this blog all about.

new record form - activity entity



Let’s say we added a Task subgrid in Contact form and we want to add related Task.

task subgrid


As you can see, Regarding field is not pre-populated.



The key here is to get the GUID of the Contact record. We can get the GUID of the Contact record through its URL and using this script Xrm.Page.context.getQueryStringParameters()._CreateFromId;

get GUID


From here, we could use OData and JavaScript function to get all the data from that Contact record. We can do the query from the ContactSet table and filter records based on the ContactID. We can use REST and utilize CRM Rest Builder to help the development.

Code Snippet:

code snippet


You could modify the above script if you want to map more fields since we already have the GUID of the Contact record.

You might get into one of these requirements along the way on your Dynamics CRM projects. This is very useful if we want fields to be mapped to Activity Entity records. Probably, I’ll look into modifying the Social Activity Pane (if there’s a way) to discuss on my next blog.