fake-xrm-easy icon indicating copy to clipboard operation
fake-xrm-easy copied to clipboard

FormattedValues problem (requires mock EntityMetadata)

Open otishone opened this issue 6 years ago • 5 comments

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);

otishone avatar Jul 31 '17 12:07 otishone

Think this is still an issue. I'd happily look at this if you point me in the right direction.

bwmodular avatar Mar 07 '18 19:03 bwmodular

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).

jordimontana82 avatar Mar 10 '18 18:03 jordimontana82

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?

bwmodular avatar Mar 19 '18 13:03 bwmodular

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?

jordimontana82 avatar Mar 19 '18 23:03 jordimontana82

Good shout, I'll give that a try....

bwmodular avatar Mar 20 '18 09:03 bwmodular