Can I change the "Code name column" of custom Class

Pawel Christow asked on March 29, 2023 11:09

Hello,

I'm having a Module Class called Company. Whenever I'm trying to update the CompanyName field I'm getting an error: The object code name '' is not valid. The code name can contain only alphanumeric characters, some special characters (_, -, .) and cannot start or end with '.'.

After some research I found the reason -> under the Code tab I have selected Code name column: CompanyName.

Wanted to ask if it's OK to change the value of the Code name column to CompanyID for example? Are there any consequences of this change?

Based on Kentico documentation: class code name (objectClassName parameter) - the code name assigned to the class in the Kentico administration interface. Identifies the class's definition in the database. For example, use the class code name when writing SQL where conditions for loading and filtering class records. (source: https://docs.xperience.io/k82/custom-development/creating-custom-modules/setting-the-type-information-for-module-classes)

I assume that it will have consequences only if I'm using this field in any SQL query.

Recent Answers


Juraj Ondrus answered on March 30, 2023 08:09

I would recommend creating DB backups before doing any changes. You should be able to change the form control but it may lead to data loss and you may need to fill out the values again. Or maybe even recreate the module class.

0 votesVote for this answer Mark as a Correct answer

Dmitry Bastron answered on March 30, 2023 17:40

Hi Pawel,

I don't think you could change it to CompanyID since it's integer field (I suppose). For code name column you can select the other string field temporarily, then change the name of your CompanyName to whatever you want, and change code name column back to the renamed field. Hopefully, it will work.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.