When adding columns to an entity/object in Creatio, there are a few column names you need to avoid. The object editor won’t stop you from using these column names, but you’ll see a build error when publishing the object if you don’t avoid these.
You’re adding columns to an object, which can be a new object or an existing one. Let’s say you’ve added a Product lookup to a Contact named UsrProduct. Later, you add a text column named UsrProductName. When you publish the changes, you get the following error:
CS0102: The type ‘Contact’ already contains a definition for ‘UsrProductName’
You check and only see the one column named UsrProductName in the object, but still the error persists and you’re unable to publish the changes.
What is happening here is the following. When you add a lookup column, the C# code that makes up the object itself really adds two properties behind the scenes, that exist only in the generated C# for the object. If we added a lookup named “TheLookup” these are:
So, in the scenario above, when we added our lookup named UsrProduct, the generated C# for the object contained two properties, one named UsrProductName and UsrProductId. It does this because when it loads the data for this object, it retrieves the selected lookup value’s Id, to store in the Id property, and the lookup value’s display value, to store in the Name property.
What causes the error is that the object editor allowed you to also add a text property named UsrProductName, so now the generated C# code contained two properties with the same name – which is what caused the error.
Obviously, to avoid the error, never add a column that is the same name as a lookup that ends in “Id” or “Name”. If you’ve already added this, and experiencing the error I mentioned above, you can fix this by simply removing the property you added ending in Name, and readd it with some other name.