How to Check Two Option Set Value in Dynamics CRM Using C#
<p>I have a plugin that triggered to run on Update based on the value of the Two Option Field. If the value is "Yes" then the plugin will run. </p>

<p>I tried to use <code>entity.FormattedValues["fieldname"].toString()</code> to get the text value from the Two Optionset Field. But didn't work.</p>

<p>I don't think that QueryExpression is not suit in my case.CMIIW</p>

<p>Here is my full code: </p>

<pre><code>if (context.InputParameters.Contains("Target") &amp;&amp; context.InputParameters["Target"] is Entity)
        {
            Entity entity = context.InputParameters["Target"] as Entity;

            if (entity.LogicalName != "incident")
                return;

            string str = entity.FormattedValues["new_createticket"].ToString();

            if (str == "Yes")
            {
                Entity ticket = new Entity("new_troubleticket");
                ticket["new_subject"] = entity.GetAttributeValue&lt;String&gt;("title");
                Guid ticketid = service.Create(ticket);

                entity["new_troubleticketid"] = new EntityReference("new_troubleticket", ticketid);
                entity["new_createticket"] = false;
            }

            service.Update(entity);
        }
</code></pre>

<p>If you have any solution, please share with me
Best regards</p>