Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2011 C#: Setting an Option Set Field

$
0
0

Hello, I'm trying to set the value of an option set field in my C# code but I am running into difficulties. I found some code examples but they are not working for me. I am using the following code:

IPluginExecutionContext context = localContext.PluginExecutionContext;

IOrganizationService service = localContext.OrganizationService;

ITracingService tracingService = localContext.TracingService;

if (localContext == null)
{
   throw new ArgumentNullException("localContext");
}

Entity targetEntity = null;
targetEntity = (Entity)context.InputParameters["Target"];

targetEntity.Attributes.Add("apd_emailstatus", new OptionSetValue(921050001));

I have the correct name for the field and the correct value, but nothing is happening when I run my code. I have my plugin set to Post-Operation running Async on Update. Does anyone have any ideas? Thank you in advance.

Mike Karls


Viewing all articles
Browse latest Browse all 8223

Trending Articles



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