Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

Accessing customer attributes, added to current case

$
0
0

Hello. I have been developing a C# plugin for CRM 4.0. The below code runs when a new case record is created. I have been trying to access the customer's GUID (which was added to the case record which was just created), so that I can later retrieve the customer's details such as e-mail address. I have tried two ways to do this: first by accessing the Value property using target_entity.Properties["customerid"].Value and also by trying to iterate over target_entity.Properties. However, both of these returned errors (as shown below in the code).

public void Execute(IPluginExecutionContext context)
{

    DynamicEntity target_entity = null;

    target_entity = (DynamicEntity)context.InputParameters.Properties["Target"];

    / *Below line gives following error:

    'object' does not contain a definition for 'Value' and no extension method 'Value'
    accepting a first argument of type 'object' could be found (are you missing a using
    directive or an assembly reference?) */

    String customerGuid = target_entity.Properties["customerid"].Value;

    /* tried alternate way to access customer GUID value by first looping
    through each property of target_entity, then accessing the Value of the customer_id
    key, but get following error:

    'The type or namespace name 'PropertyValueCollection' could not be found (are you
    missing a using directive or an assembly reference?)'

    Tried to import it with System.DirectoryServices but does not work, as
    DirectoryServices is not recognised */

    foreach (PropertyValueCollection value in target_entity.Properties)
    {
        if (value.PropertyName == "customerid")
        {

            String customerGuid == value.Value;

        }
    }

}



Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>