I a trying a very simple stuff. getting value of a lookup field from my Ms CRM plugin.
But I am not getting any thing i.e Empty.
below is my code.
------------------------------------------------
IPluginExecutionContext context = localContext.PluginExecutionContext;
IOrganizationService service = localContext.OrganizationService;
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parmameters.
Entity entity = (Entity)context.InputParameters["Target"];
if (entity.LogicalName == "ms_case")
{
try
{
String y = entity.FormattedValues["abaxis_look"].ToString();
// above is not even given me the simple string of my lookup just trying to get it
Guid y = new Guid();
EntityReference ownerLookup = (EntityReference)entity.Attributes["ms_produkt"];
var productName = ownerLookup.Name;
y = ownerLookup.Id;
entity.Attributes["abaxis_autonr"] = y;
catch (FaultException ex)
{
throw new InvalidPluginExecutionException("An error occurred in the plug-in.", ex);
}