Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Set moderation status for document set programmtically

$
0
0

Hi,

in my sharepoint environment there is a document library with "content approval" enabled.
I have created a custom content type named "My Document Set" based on the "Document Set" Content Type.

For this custom content type I have created an EventReceiver (ItemAdded, ItemUpdating, ItemUpdated) that checks several things and sets permission on the Document Set etc.

Now I wanted to add a functionality to this EventReceiver, that automatically sets the approval status for the document set relying on the value of its field values.

To check whether setting moderation status in an EventReceiver works, I just added the following piece of code at the end of the ItemAdded method in the event receiver:

item.ModerationInformation.Status = SPModerationStatusType.Approved;
item.ModerationInformation.Comment = "Automatic approval";
item.Update();

Additionally I have added some log messages before and after this part that logs the approval status.
Now when I create a "My Document Set" item i can see in the log file that it gets the approval status "Approved" but when I have a look at the document library I can see that it is not approved. Also the comment is missing :-(.

Can somebody tell me what I am doing wrong?
Or is it not possible to set the approval status of a custom document set programmatically?

Best regards
Marco




Viewing all articles
Browse latest Browse all 11508

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>