views:

145

answers:

1

Seeing if anyone else has had this problem and a resolution to it.

I have a visual studio sequential workflow on a list (not a library) which does NOT use tasks, the approval process is done through the Approve/Reject OOTB buttons on the list item. The approval is a 2 stage approval, whereby if the 1st stage is completed (via clicking the Approve OOTB button), i reset the ModerationInformation.Status from Approved back to pending then send an email to the 2nd stage approver.

My problem is, when i set the the ModerationInformation.Status back to Pending from Approved so there is never an approved version, the Creator loses permissions to view the item, and i get the "cannot find item" error from SharePoint for the person who created the item. The 1st and 2nd level approvers and anyone with approve rights CAN still see the item.

Some more background information. the code i am using to update the moderationinformation is

I get the properties from the workflow event and get a hook into the listitem

properties.Item.ModerationInformation.Status = SPModerationStatusType.Pending; properties.Item.Update();

can anyone help.

A: 

Try using properties.Item.SystemUpdate(); this prevents SHarePoint from triggering any attached EventReceivers etc. I've had the same thing happen also. IMHO this is related to the fact that the item goes into update mode, then SharePoint basically has taken control over the item (seeing as workflows are usually run as the System account) but still sends you back to the the return url (i.e. the EditItem page of the list).

Since SharePoint is probably still doing work on the item (and when you use item.Update() it goes through all events etc. etc.) you cannot open it anymore, because you are not the system account.

When SharePoint finishes (after sent the emails etc.) the item is accessible by users again.

Like I said, I had the same thing happen during long running (i.e. longer than 2 to 3 seconds) EventReceivers / Workflows.

Colin
SystemUpdate makes no difference in this scenario to the outcome. I can leave the item 2 days and the creator still does not have access to it so it is not the duration of the workflow/event handler. It is to do with SharePoint removing some permissions on the list item, so I decided to set the creator permissions again during the update. that seemed to fix the problem. but thanks for your suggestion
Gavin Morgan