Access the list item information in ItemCheckedIn event handler that's passed from ItemUpdating EventHandler

I am currently trying to develop an event receiver that checks if an item being updated is already in the ItemCheckedIn event handler.

I have read that in the properties.AfterProperties object it shows the what is being updated on a List Item. What I have seen is that, the value I am setting in ItemUpdating or ItemUpdated eventhandler method will not be  visible or available in ItemCheckedIn event handler. So is there any way I can access this value? I need to pass the latest value of the item's column info. and be available in itemcheckedin method.I know, I can not use properties.AfterProperties["  "]  in itemcheckedin event since its not available.

If I explain my scenario,when the user upload a document he will select a drop down,public and confidential,and when confidential is selected am triggering a custom action such that,3 people pickers were populated for entering the user names for giving access programmatically. I can say its a kind of approval workflow i am trying to implement through visual web part and event receiver -without using SP D 2013 / WF Manager. The strange thing is that, it works in my test and staging environment, but fails in production.

public override void ItemUpdating(SPItemEventProperties properties)
    {
        base.ItemUpdating(properties);

        try
        {
            if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null
            && properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
            {
                if (IsConfidential(properties))
                {
                    SetRoleChanged(properties);
                }
            }
    }
  public void SetRoleChanged(SPItemEventProperties properties)
    {
        try
        {
            string currentRead = 
        Convert.ToString(properties.AfterProperties[READACCESSCOL]);
            string oldRead = 
        Convert.ToString(properties.BeforeProperties[READACCESSCOL]);
            string x2 = 
        Convert.ToString(properties.ListItem[READACCESSCOL]);
        } 
       string currentView = 
        Convert.ToString(properties.AfterProperties[VIEWACCESSCOL]);
         string oldView = 
         Convert.ToString(properties.BeforeProperties[VIEWACCESSCOL]);
            if (currentView != oldView)
            {

                properties.AfterProperties["ViewChanged"] = "true";   
            }

      public override void ItemUpdated(SPItemEventProperties properties)
       {
        base.ItemUpdated(properties);
       }

Would like to know any other approaches I can implement for achieving this?  




  • Edited by SaMolPP Tuesday, June 02, 2015 8:20 AM
May 31st, 2015 10:26am

I don't think you will get value using AfterProperties in itemcheckedin method as it is Asynchronous. Try using itemcheckingin  or modify the elements.xml for itemcheckedin event as Synchronous. Refer to the following post for more information

http://blogs.technet.com/b/stefan_gossner/archive/2011/11/10/using-synchronous-quot-after-quot-events-e-g-itemupdated-in-sharepoint-2010.aspx

Free Windows Admin Tool Kit Click here and download it now
June 1st, 2015 8:26am

Prasath,

I have updated my  question with details.

June 2nd, 2015 8:19am

Hi,

You can add some logs in your code to monitor the data in production. Or check the settings in test environment and production.

Best Regards

Free Windows Admin Tool Kit Click here and download it now
June 18th, 2015 3:00am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics