I have a document library in which there is one field approver (multi - value). There is an event receiver for item updating of the document library that I want to validate user while changing the properties of document.

I want to check if the previous value in user field and new value of user field must be same. To do that I have written following code:

string workflowStatus = Convert.ToString(properties.ListItem[FieldNames.WorkflowStatus]);
if (!string.IsNullOrEmpty(workflowStatus))
    if (!workflowStatus.Equals(WorkflowHelperData.Constants.Approved))
        if (!General.GeneralMethods.CheckUsersSame(properties.ListItem,properties.AfterProperties,FieldNames.Approver1))
            properties.ErrorMessage = "Change in approver field is not allowed";
            properties.Status = SPEventReceiverStatus.CancelWithError;

The method to check the users are same or not is as follows:

public static bool CheckUsersSame(SPListItem sPListItem, SPItemEventDataCollection sPItemEventDataCollection, string fldName)
    SPFieldUserValueCollection userColl = sPListItem[fldName] as SPFieldUserValueCollection;
    SPFieldUserValueCollection userColl1 = sPItemEventDataCollection[fldName] as SPFieldUserValueCollection;
    if (userColl == userColl1)
        return true;
    return false;

After executing the code I am getting userColl1 to null

What should I do to compare new and old field values?

2 Answers 2


I have the same problem and found below fix:

var userLogin = properties.AfterProperties["UserField"].ToString();
var userFieldValue = new SPFieldUserValue(web, userLogin);
var user = web.EnsureUser(userFieldValue.LookupValue);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.