3
votes

In Sitecore, for all the users who do not have administrator privileges(Is administrator checkbox not clicked when creating the user) when they try to edit an item they have to select "Lock and Edit" option which would create a new version instead of editing the existing one. Is there a way I can make non admin users edit an item without creating a new version ? I am hoping whether this could be done using a user role.

3

3 Answers

6
votes

Here is the code responsible for creating new versions while editing Sitecore items:

public Item StartEditing(Item item)
{
  Error.AssertObject((object) item, "item");
  if (!Settings.RequireLockBeforeEditing || Context.User.IsAdministrator)
    return item;
  if (this._context.IsAdministrator || StandardValuesManager.IsStandardValuesHolder(item) || !this.HasWorkflow(item) && !this.HasDefaultWorkflow(item) || !this.IsApproved(item))
    return this.Lock(item);
  Item obj = item.Versions.AddVersion();
  if (obj != null)
    return this.Lock(obj);
  else
    return (Item) null;
}

Apparently Sitecore creates new version if item is in a final state of any workflow unless user is administrator.

You could try to change the RequireLockBeforeEditing setting but it will disable not only new version functionality but the locking functionality as well.

2
votes

this is Sitecore default behaviour for locking.

Sitecore uses item locking to ensure that two different users can‘t edit the same item at the same time. If two or more users somehow managed to edit the same item simultaneously, only the changes that were made by the user who clicked Save last will be available. All the other changes will be lost. Item locking is a system whereby you lock the item you are editing and prevent other users from editing this item until you unlock it again after you have finished editing the item.Item locking works differently depending on the tools that you are using. In the Page Editor, you can lock an item before you start to edit it.In the Content Editor, you must lock an item before you can edit it.

You can find more about locking Here

Please also look at this settings from web.config :

     <!--
     REQUIRE LOCK BEFORE EDITING
        If true, the user must have a lock on a document before
        he can edit it, otherwise it is always ready for editing

      -->
     <setting name="RequireLockBeforeEditing" value="true"/>

    <!--
        KEEP LOCK AFTER SAVE FOR ADMIN USERS
        Set this value to true if you want to Administrator users to keep the lock on     an item after saving
        it in the Page Editor.
        Notice: For regular users, the "Keep Lock After Save" item in the core database will determine whether
        to keep the lock or not.
        Default value: false
   -->
    <setting name="KeepLockAfterSaveForAdminUsers" value="false"/>
    <!--
   AUTOMATIC LOCK ON SAVE
        If true, the a lock is automatically taken on an item
        when a user saves the item.
   -->
  <setting name="AutomaticLockOnSave" value="false"/>
    <!--
  AUTOMATIC UNLOCK ON SAVED
        If true, the a saved item is automatically unlocked after
        saving.
    -->
    <setting name="AutomaticUnlockOnSaved" value="false"/>
2
votes

You can turn this off by editing this option in de web.config ->

<setting name="RequireLockBeforeEditing" value="true"/>

Read more about it here

Good luck!