Hi how could i use a event receiver based on a document library, to se if the user has unpublished a dokument in the library, in the mean time also i want to update a field in the document library when the user unpublish the document?
Any kind of help or suggestions...
============================`
UPDATE
I only want to se if the user has entered unpublish on a document then i want to update a field value, if the document is published do nothing..
public override void ItemUpdated(SPItemEventProperties properties){
//was published/approved before
if(properties.BeforeProperties["ows__ModerationStatus"] == 0){
//is now unpublished/pending
}
}
UPDATE 08:47
When user enter unpublish i want to clear a field but the field does not get updated? in a document library
//was published/approved before
if (properties.BeforeProperties["ows__ModerationStatus"].ToString() == "0")
{
//is now unpublished/pending
if (properties.AfterProperties["ows__ModerationStatus"].ToString() == "2")
{
string mycol_internal = "";
using (SPWeb web = properties.OpenWeb())
{
mycol_internal = web.Lists[properties.ListId].Fields["DisplayNameField"].InternalName;
web.AllowUnsafeUpdates = true;
}
properties.AfterProperties[mycol_internal] = "";
}
}
I am using ItemUpdated