"Operation is not valid due to the current state of the object" when calling "BreakRoleInheritance" for an SPListItem

This error will occur if you have new list item in code that you haven't yet called the update method for.

The BreakRoleInheritance method directly amends an item without the need for you to call update to set the changes.  This means that the method is making direct updates to the list item in the database but if you haven't called update since creating the item in code then it doesn't yet exist to break the role inheritance on!

 

[UPDATE]

The following is an additional list of methods and properties that cannot be used / accessed until an SPListItem has been updated:

  • AllRolesForCurrentUser
  • Audit
  • CheckPermissions
  • Delete
  • DoesUserHavePermissions
  • EffectiveBasePermissions
  • ForwardLinks
  • ResetRoleInheritance
  • ReusableAcl
  • RoleAssignments
  • UniqueId
  • Url is blank

 

This was just a quick test, I may have missed some off but it's a start.

Leave a Reply