API
Version 7.x > API > Role with a space View modes: 
User avatar
Member
Member
kelly-lion - 12/10/2013 12:46:13 PM
   
Role with a space
Dealing with a database that has been upgraded from 6 to 7. Consultant created a role with a space in it and provided us with tools to manage membership in that role.

Now, on version 7, the tool errors out with

Unhandled Exception: CMS.DataEngine.CodeNameNotValidException: The object code n
ame 'Active Member' is not valid. The code name can contain only alphanumeric ch
aracters, some special characters (_, -, .) and cannot start or end with '.'.
at CMS.DataEngine.AbstractInfoProvider`2.SetInfo(InfoType info)
at CMS.SiteProvider.RoleInfoProvider.SetRoleInfoInternal(RoleInfo roleInfoObj)
at CMS.SiteProvider.RoleInfo.SetObject()
at CMS.SettingsProvider.BaseInfo.SetParent(GeneralizedInfo parent)
at CMS.SettingsProvider.BaseInfo.TouchParent()
at CMS.Synchronization.SynchronizationHelper.TouchParent(BaseInfo infoObj, TaskTypeEnum taskType)
at CMS.Synchronization.SynchronizedInfo`1.DeleteData(Boolean logObjectChange)
at CMS.DataEngine.AbstractInfoProvider`2.DeleteInfo(InfoType infoObj)
at CMS.SiteProvider.UserRoleInfoProvider.DeleteUserRoleInfoInternal(UserRoleInfo infoObj)
at CMS.SiteProvider.UserRoleInfoProvider.RemoveUserFromRole(UserInfo ui, RoleInfo ri)
at CMS.SiteProvider.UserRoleInfoProvider.RemoveUserFromRole(Int32 userId, Int32 roleId)

Any quick way to fix this since the role is still in use on the site?
Thanks,
Kelly

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/12/2013 8:25:20 AM
   
RE:Role with a space
Is the role dependent on a 3rd party or external system? If not, I'd simply make the modification to the role name and code name and fix any code behind if needed. That would be a more robust fix/solution than attempting to work around the broken code someone else created.

User avatar
Member
Member
kelly-lion - 12/12/2013 3:30:17 PM
   
RE:Role with a space
You are of course correct, that would be the best solution. I just don't know where all else they used it. I'll fix it the right way, but it will require digging and testing.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/13/2013 6:27:34 AM
   
RE:Role with a space
Open Visual Studio and simply do a Ctrl+F and find the syntax in the code. That will probably cover most of your issues. There could be instances where they are looking for the role in a macro which is stored in the database which the simple find and replace will not work. BUT I'd assume you already know what areas on the website might already have permissions set based on that role so you could check to see if they are working as expected.