Strange error when trying to update field in InitFields

We are getting this error in Litium 8.
In DefinitionSetup.cs InitFields
We have change so we always update fields, because all fields and templates are set in the code.
But we are getting this error. So the DefinitionSetup craches.
The strange part is that the field LogotypeMain is not multi culture, and never has been or has been changed. And this happens on every field.

Is this a bug?

2021-11-26 09:28:38.1850 [App:01] [2af90239-afeb-4fdb-bb0b-78530fa1e9d1] [ERROR] [] Litium.Application.Runtime.ApplicationStartupEngine - Litium.Accelerator.Definitions.DefinitionSetup -> Validation error for FieldDefinition`1(SystemId: 1efb20c2-6eea-452d-a714-92ca9da67848, Id: LogotypeMain), MultiCulture: 'You can't change an existing field to multi language.'. Litium.Validations.ValidationException: Validation error for FieldDefinition`1(SystemId: 1efb20c2-6eea-452d-a714-92ca9da67848, Id: LogotypeMain), MultiCulture: 'You can't change an existing field to multi language.'.
   at Litium.Validations.ValidationServiceExtensions.ThrowExceptionIfError[T](ValidationService service, T entity, ValidationMode validationMode)
   at Litium.Application.Data.Batching.BatchDataImpl.Execute[T](T entity, ValidationMode validationMode)
   at Litium.Application.Data.Batching.BatchDataImpl.WrapAndExecute[T](T entity, ValidationMode validationMode)
   at Litium.Application.Data.Batching.BatchDataImpl.Update[T](T entity)
   at Litium.Application.FieldFramework.FieldDefinitionServiceImpl.Update(FieldDefinition fieldDefinition)
   at Litium.Accelerator.Definitions.DefinitionSetup.InitFields(IEnumerable`1 fields) in C:\git\RollcoL8\Src\Litium.Accelerator\Definitions\DefinitionSetup.cs:line 243
   at Litium.Accelerator.Definitions.DefinitionSetup.Start() in C:\git\RollcoL8\Src\Litium.Accelerator\Definitions\DefinitionSetup.cs:line 98
   at Litium.Accelerator.Definitions.DefinitionSetup.StartAsync(CancellationToken cancellationToken) in C:\git\RollcoL8\Src\Litium.Accelerator\Definitions\DefinitionSetup.cs:line 354
   at Litium.Application.Runtime.ApplicationStartupEngine.<>c__DisplayClass6_0.<<Start>b__2>d.MoveNext()

Litium version: 8

This did not happen in L7?

No, never seen it in L7 and we are using it in most projects. But it happens in 2 L8 solutions. And it’s the same code in both.

I have also seen the error myself some time ago, report a bug with reproducible steps please.

So it seems it was not a bug and closed for this reason:

The item.SystemId and currentField.SystemId are different. In order to update the item, the item.SystemId should be same as currentField.SystemId.

All entities get their assigned SystemId during creation, when you fetch the field you are not fetching it by the SystemId and instead the Id. That’s make the item.SystemId not match currentField.SystemId even that item.Id matching currentField.Id and when trying to update based on the item no field will be found and then the settings will be false that throws the validation errors. This is not anything that have been changed and is working should work the same from Litium 5.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.