I recently experienced an OptionSetValue behaving like an integer in a method of my plugin. Previously, and with all other OptionSetValues, to retrieve the integer value, I have used the pattern:
localIntegerVariable = (new_myEntity.GetAttributeValue<OptionSetValue>("new_myOptionSetAttribute")).Value;
That no longer works in the one of the methods of the plugin. If i treat it like an integer, it works.
localIntegerVariable = (new_myEntity.GetAttributeValue<int>("new_myOptionSetAttribute"));
Strangely enough, in the main section of the same plugin before I retrieve the pre image entity, I treat the same attribute as an OptionSetValue like below and it works just fine.
int incominglocalIntegerVariable = temp.GetAttributeValue<OptionSetValue>("new_myOptionSetAttribute") == null ? _OSV_Empty : temp.GetAttributeValue<OptionSetValue>("new_myOptionSetAttribute").Value;
I have verified that the definition of new_myOptionSetAttribute in the entities.cs file is an OptionSetValue. I have also verified that the definition in CRM is an OptionSet value.
Has anyone experienced this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…