C# Code · Customization and Configuration · Dynamics Plugins

{Dynamics CRM 365 CE} Using a Party List as a Lookup for a Quickview Form

Dynamics Community Forum Question –

My goal is to create a quick view for a few fields for our contact record on one of our activities (in this case the phone call). I can’t use the “Call from” because it’s a Party List and not a Contact Lookup field.

Solution Approach

Create new custom field lookup data type and point it to Contact. Add new quick view form on Phone call based on this lookup field.

Now add below plugin code in your assembly.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xrm.Sdk;

namespace Microsoft.Crm.Sdk.Samples
    public class PhoneCallCreate : IPlugin
        public void Execute(IServiceProvider serviceProvider)
            // Obtain the execution context from the service provider.
            Microsoft.Xrm.Sdk.IPluginExecutionContext context = (Microsoft.Xrm.Sdk.IPluginExecutionContext)

            // The InputParameters collection contains all the data passed in the message request.
            if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
                // Obtain the target entity from the input parameters.
                Entity entity = (Entity)context.InputParameters["Target"];

                // Verify that the target entity represents an account.
                // If not, this plug-in was not registered correctly.
                if (entity.LogicalName == "phonecall")
                    if (entity.Attributes.Contains("from") && entity["from"] != null)
                        EntityCollection ecCallFrom = entity.GetAttributeValue("from");
                        if (ecCallFrom != null)
                            foreach (Entity entityCallFrom in ecCallFrom.Entities)
                                EntityReference partyId = entityCallFrom.GetAttributeValue("partyid");
                                    entity["new_contact"] = partyId;

Next register steps on Create message- Phone call Entity- Pre-operation- Sync.

Final Outcome.

Hope this helps!

One thought on “{Dynamics CRM 365 CE} Using a Party List as a Lookup for a Quickview Form

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s