I have a document library on my SharePoint online site, when a user uploads a file in the library a c# itemAdded event is triggered to read the file and store the information in a separate list. This all works perfect. My problem comes in where i need to write any exception errors to a field in the document library. I have a multiline text field in the library already and there are several methods in my code, each method needs to be able to write to the field. How can i do this from the catch method. Any Help would be greatly appreciated.
1 Answer
Try this inside the catch block:
catch(Exception ex)
{
SPListItem item = properties.Listitem;
item["MultiTextFieldName"] = ex.Message;
item.Update();
}
-
I will obviously have to pass the properties to all the methods to use this code?– EgorCommented Dec 8, 2014 at 15:21
-
You need to pass the ListItem. This is the best way to get hold of that object. Commented Dec 8, 2014 at 15:24
-