Wednesday, November 3, 2010

SharePoint 2010: Editing an item whose modified version is in pending for approval, causes runtime exception

In SharePoint 2010, You can enable content approval by going to ‘Versioning Settings’ section of list settings page as shown below. The error I’ve found can only be found if we choose “Only Users who can approve items (and the author of the item)” as an option in “Who should see draft items in this list?”.

image

Figure 1: Content Approval settings page

Now let’s have a scenario where three users are involved. The first user, say admin, is in administrator group. There are other two users: contributor1 and contributor2 who belongs to contributor group. Say there’s a list MyList where Content Approval is enabled for the list and only users who can approve the item and the author of the item can see draft items. Now follow the steps:

  1. User contributor1 edits an item. And the draft item is pending for approval by admin user.

  2. User contributor2 visit the item and try to edit the item. When user click edit link the edit dialog comes up but when user click Save button the following error message is shown (if you have enabled stack trace):

image

Figure 2: Exception when try to edit an already pending item

The error message is shown below:

Cannot complete this action.

Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: Cannot complete this action.

Please try again.<nativehr>0x80004005</nativehr><nativestack></nativestack>

Expected Behavior

The expected behavior would be to disable the save button for item already in pending approval status. Or there should have an settings page where admin can define what to do for items whose draft version is in pending approval stage. The options could be:

  • Hide the item from users who can’t see draft items
  • Show the item as readonly to users who can not see draft items (so edit link could be disabled for users).

 

Conclusion

So if an updated item is waiting for approval and if any other user, except the author and user who can approve, try to edit the item, he/she’ll get the error page shown above. The error is only shown when options are selected for viewing draft items by only author and person who can approve items. Though draft item can be edited/viewed by author and approver, other users can see the old item and can edit. So the error is evident if other users try to edit the item.

No comments:

Post a Comment