update custom fields attributes in custom types - reference object custom attribute data wiped out
nxverma opened this issue · 1 comments
Hi Team,
We notice weird behaviour when we update custom fields attributes in custom types , all Entities (ex Business Unit) which referring this custom type as custom attributes loose all data / values for existing attributes . we have to again set values in Entity for custom attributes. It is very risky in production as we don't want existing custom attribute values wiped out when we do add/update attributes in referenced custom type.
When I checked with CT team , they said while applying any change in custom attribute in ref custom Type we need to pass all attributes in update request. Need to check in TF code if we update any CustomType , will TF code pass all attributes of custom types ???? or only updated attributes
Hi @nxverma!
I am not sure I understand what is going on.
When a commercetools_type
gets updated we parse the fields that have changed, and create updates based on these: https://docs.commercetools.com/api/projects/types#update-actions. So when adding the field bar
to the below it will just create an update action to add bar
, but change nothing else.
resource "commercetools_type" "my-custom-type" {
...
field {
name = "foo"
label = {
en = "foo"
nl = "foo"
}
type {
name = "String"
}
}
# This gets added
field {
name = "bar"
label = {
en = "bar"
nl = "bar"
}
type {
name = "String"
}
}
}
Do you have an example where it is going wrong for you? I played around a bit with it, but any entities implementing this custom type do not lose the data in previously set custom fields