Hi I have a lookup filed in CRM form i need to set the look up field on Pre-Operation;
For example- if I click on New in crm Form, It need to show look up value.
Entity targetEntity = pluginUtils.GetTarget();
if (targetEntity != null)
{
try
{
if (targetEntity.Attributes.Contains("code")) //&& targetEntity.Attributes.Contains("andid") && targetEntity.Attributes.Contains("organization"))
{
Entity alerRef = resolveLookUpValue(targetEntity.GetAttributeValue<string>("code"), targetEntity.GetAttributeValue<EntityReference>("andid").Id, targetEntity.GetAttributeValue<string>("organization"), pluginUtils);
if (alerRef != null)
{
Entity companyAssociationEntity = new Entity("companyassociation");
companyAssociationEntity["id"] = alerRef.ToEntityReference();
}
}
}
catch (Exception ex)
{
throw new InvalidPluginExecutionException("Unable to Resolve lookup value" + ex.Message + ex.StackTrace);
}
}