# Strange error when trying to update field in InitFields

**URL:** <https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325>\
**Category:** Questions\
**Tags:** litium-8\
**Created:** [November 26, 2021, 8:36am UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325 "2021-11-26T08:36:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [November 26, 2021, 8:36am UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/1 "2021-11-26T08:36:50Z")

</div>

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?

```auto
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

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 29, 2021, 4:43pm UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/2 "2021-11-29T16:43:34Z")

</div>

This did not happen in L7?

---

<div class="post-metadata">

**Author:** ![Ericsj11](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ericsj11/32/899_2.png) [@Ericsj11](https://forum.litium.com/u/Ericsj11)\
**Post date:** [November 29, 2021, 4:50pm UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/3 "2021-11-29T16:50:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [November 29, 2021, 4:52pm UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/4 "2021-11-29T16:52:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 1, 2021, 3:11pm UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/5 "2021-12-01T15:11:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [December 1, 2021, 6:44pm UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/8 "2021-12-01T18:44:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [December 29, 2021, 6:45pm UTC](https://forum.litium.com/t/strange-error-when-trying-to-update-field-in-initfields/2325/9 "2021-12-29T18:45:40Z")

</div>

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