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

Getting vlaue/Id/Name of lookup field in a form using CRM plugin

$
0
0

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);
}


Viewing all articles
Browse latest Browse all 55831

Trending Articles



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