I have created a SharePoint2010 list with 20 columns. which has 2 key columns cid and tid of the user. There is an application, whenever it is initiated a new row is created in the Sharepoint list with the cid and tid values added to the respective columns.

Now when the row is created with cid and tid, and event should fire and pass the cid and tid values as parameters to an external webservice, get the data and populate rest of the columns in that row.

Can anyone help me with any code samples to write the event handler on the list.

I created a Visual Studio project and added a event receiver to the project and added the web reference.

just need some help in writing the code in the event receiver.

  • namespace abcEventHandler.abcEventReceiver { public class abcEventReceiver : SPItemEventReceiver { public override void ItemAdded(SPItemEventProperties properties) { string cid = (properties.AfterProperties["CID"]).ToString(); string tid = (properties.AfterProperties["TID "]).ToString(); try { using (SPSite oSite = new SPSite(properties.Web.Url)) { using (SPWeb oWeb = oSite.OpenWeb()) { – Kumar Mar 21 '13 at 21:36
  • This is what i started and trying to figure out the logic to call the webservice, get the data and populate the list columns. – Kumar Mar 21 '13 at 21:38

If you are looking for getting started samples, you should go through the series of articles from Karinne Bosch, which also explains some tricks http://karinebosch.wordpress.com/walkthroughs/event-receivers-theory/

In your situation, i believe you should go for ItemUpdated, still calling a web service from the handler brings more issues, particularly in cases of timeouts, authentication - have you thought this through??

I would have chosen a simple workflow with updating of all fields, while you wait for a change on those 2 fields which are important (here the only issue is that prior to SharePoint 2013, there is not call Web Service activity - unless you already have Nintex, K2)

  • Thanks Marius. I'm calling the webservice to get the data so that i can populate other columns in the list. I'm using the ItemAdded event so that whenver a new row is created in the SP list with the two fields then the event should fire and go the webservice and get the data. – Kumar Mar 21 '13 at 21:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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