fake-xrm-easy
fake-xrm-easy copied to clipboard
FormattedValues problem (requires mock EntityMetadata)
Hi,
I'm trying to use FormattedValues
property afterwards on the entity and there are some problems with values of this property.
When I'm simply assigning OptionSetValue
value to the field (using latebound or earlybound) afterwards any FormattedValue
is not set in the result. From the other hand when I'm setting up enum value to enum property then FormattedValue
is generated, but when I try to obtain field value I get InvalidCastException
when getting attribute of OptionSetValue
type.
This will generate FormattedValue but You will get InvalidCastException
:
contract["new_status"] = new_contractsatusenum.Active;
This will result proper field value, but no FormattedValue will be generated:
contract["new_status"] = new OptionSetValue(4);
Think this is still an issue. I'd happily look at this if you point me in the right direction.
Hi Ben, I think this is not a so easy one as in order to get FormattedValues we´ll need EntityMetadata to be injected so that the formatted values can be returned (i.e. labels, etc).
Hmm, I thought as much, or you would have already worked on it ;-) Shame, as it would be really handy. Can you think of any workarounds in the meanwhile?
Hi Ben, One workaournd I can think of would be to inject the FormattedValues in each entity that gets passed to the .Initialize() method so that it would return what you expect to return maybe?
Good shout, I'll give that a try....