Developer Forum »
Default value for EnumerationPropertyClass does not work
0 posts
Relatude

Hi,

I have an EnumerationPropertyClass referring to an Enumeration with two Values:

  • Private (1)
  • Company (2)

In the EnumerationPropertyClass, I have now changed the Default Value from 0 to 1, expecting "Private" to become the default value. This does not seem to work as there's still no default value when creating a new object of the class containing this EnumerationPropertyClass.

From Content.definition:

<Property Guid="9ad5f689-3869-4611-9b6a-6468fb9095d9" CodeName="Type" PropertyClassGuid="7d08c6fb-28f7-4d30-b407-439e018d2402">
  <DataValues>
	<Integer Guid="04c9d779-672a-4d8e-ad50-1cc884b21dc1" Key="Value" Name="type" Default="1" />
  </DataValues>
  <Settings>
	<EnumerationReference Key="Enumeration" Value="bbf236ab-c687-4a8e-bc76-1435af6ad77c" />
  </Settings>
</Property>

Do you have any idea why?

Sincerely, Anna

181 posts

It should set the default value, and we'll investigate, but as a short term solution, you can set the value  to 0 for the option you want to be default. 

Vidar

47 posts

Thank you for help and good advice

0 posts
Relatude

Hi, 

Setting the value to 0 have caused quite a lot of problems, as we had a lot of old documents that used this property. Now all the old documents that were set to "Private" (previously 1) is now set to "Company", while the documents set to "Company" (previously 2) now is set to nothing.

Do you have another solution? Have you come any further in your investigation?

Anna

181 posts

Hi! 

I wasn't aware that there were existing data using the enumeration. An enumeration property is mapped to an int column in the database. If you change the definition of the enumeration, the system will map the existing database values to the new enumeration values, and cause the problem you have experienced.

The other solution to set the default value, is to set the value in the OnNew method in the partial class in WAF_Custom.

this.EnumPropName = 1;

 

We have also investigated why the default value isn't set. A fix will be released next week in a new build.

47 posts

Hi,

Is this fix available by now?

181 posts

Hi! 

The new nuget (2077) was just released: https://www.nuget.org/packages/Relatude.Server/.

It fixes the default value bug for Enumeration

 

1