Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Not getting previous value of List in itemUpdated event receiver

$
0
0

 I have scenario that if i update any item in a listA(in sitecollection1) it should update in another listB(sitecollection2)..

I am using beforeproperties it is throwing null value..

 but i need that previous value of listA which i have updated just now in "itemupdated" event receiver

here is my code

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

            using (SPWeb web = new SPSite("http://natex2:1990/sites/ess/facilities/spaces").OpenWeb())
            {

                web.AllowUnsafeUpdates = true;

                SPList list = web.Lists.TryGetList("LocationDetails");
                 //string querry = properties.ListItem["Title"].ToString();
                 string querry = properties.BeforeProperties["Title"].ToString();
                SPQuery qury = new SPQuery();

                qury.Query = "<Where><Eq>" +
                    "<FieldRef Name='Title' />" +
                   "<Value Type='Text'>" + querry + "</Value>" +
                  "</Eq>" +
                  "</Where>";
                SPListItemCollection coll = list.GetItems(qury);

                foreach (SPListItem item in coll)
                {
                    string data = properties.AfterProperties["Title"].ToString();
                    item["Title"] = data;
                    list.Update();
                }
                
                web.AllowUnsafeUpdates = false;
            }

        }

please anybody help me i need urgent help



Viewing all articles
Browse latest Browse all 7589

Trending Articles



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