Document Library- Item Event Listener - sharepoint-2010

I have created a Document library in SharePoint 2010 site. Now I want to execute some code whenever new document is added to this Document library.
How do I implement this? Do I need to implement Item Event Listener? and how this Item Event Listener will be connected to Document library. Can I call a Web service into Item Event Listener?

Be careful reading links that pertain to sharepoint 2010. Sharepoint 2007 links may contain out of date logic.
In how they dispose of SPSite/SPWeb objects
Not using properties.Cancel
EventFiringEnabled instead of DisableEventFiring()
http://msdn.microsoft.com/en-us/library/ff728093.aspx
http://msdn.microsoft.com/en-us/vstudio/Video/ff623003
For binding the receiver to a list
http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/19d9ccac-0bfd-4923-8518-8decedc4617d
And it you have the permissions right, you should be able to do most things in an event receiver. Look into elevating the user context.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx

Related

Outlook add-in office.js on appointment saved

Is it possible in an office add-in (using office-js) to detect when the user creates an appointment in Outlook ?
No, there is no straight forward way via Office-js.
Basically Outlook web addins are scoped to the item in preview, i.e, user invokes the add-in on a mail item (message / calendar event) and add-in can work with the item it was invoked on.
But if your addin has ReadWriteMailbox permission, there is a roundabout way to acheive the same using REST
Get REST token using Office.context.mailbox.getCallbackTokenAsync API.
Using REST push notifications you can listen on event created.

How to capture the tick event of the task checkbox on 'Outlook Today'? VSTO Add-in

I'm developing an Outlook Add-in, and currently I have no idea on how to capture the task's checkbox (mark complete) tick event -- particularly on the 'Outlook Today' view. I'd like to override it with my own function.
Refer to the attached image as reference to the checkbox being referred to.
Outlook Today Task
The Outlook Today page is not a typical area that can be integrated with. It is possible though, as it is basically an .html page; see: https://technet.microsoft.com/library/cc750169.aspx. However, this is 20 year-old technology...
If you are mainly interested in trapping changes to that task, then you can trap the Items.ItemAdd event for the Tasks folder and do whatever you like with the modified Task.
The Outlook object model doesn't provide anything for the Outlook Today page. It just lists items from your folders. So, you may consider handling the following events to get the job done:
The ItemChange event of the Items class which is fired when an item in the specified collection is changed.
The PropertyChange event of Outlook items which is fired when an explicit built-in property of an object is changed.
Both events are fired when you mark the task as completed. But in case of the PropertyChange event you need to subscribe to each task item individually which is not really convenient.

Outlook 2013 customization and integration in exchange online

I want to customize the appointment window used in Outlook. I want add few custom fields. I am using VSTO (VS2013) to develop this addin.
So far I have added a button in ribbon of appointment tab. On click of which I am opening a new form with custom fields. Now when user completes the form and other appointment details and appointment is saved then along with all appointment data, custom data entered by user should also get emailed to recipients.
And also that custom data would be stored in Exchange, and later that data can be queries to generate report.
So my question is - how do override the save appointment event so that I can add additional data in appointment and also how do I save it to exchange online using office 365.
Please advise.
Thanks.
When you are using an Exchange account which is the case with Office 365. The UserProperties of an Outlook item is kept in Exchange.
You can persist the custom data in UserProperties
If you want to Save your custom data when the appoitment is saved. You should put an event handler in the AfterWrite event. See AppointmentItem event list.

SharePoint 2010: trying to understand life-cycle issues with visual web part

I am building a visual web part which has a number of user-configurable properties. The web part will display news items and, optionally, automatically switch to the next item after a defined pause.
The problem I'm having is that the user control part has a timer which fires events. These events reenter the user control (without going through the web part) and I see that when this happens the user control is in an unitialised state - i.e. the custom properties of the web part have not been applied. This causes the control to behave in it's default manner.
What am I doing wrong?
When you set property in your webPart, you need to bubble it down to the User control.
See creating custom properties for visual webparts:
http://patricklamber.blogspot.com/2010/05/how-do-i-create-custom-properties-in.html

SharePoint 2010, Save As Site Template And Event Reciever Feature

I have an event reciever feature on my SharePoint 2010 site where it runs when a survey is completed or is about to be deleted or updated. When I save my site as site template, the event reciever feature is activate before I perform the save. Now when I create a subsite using the site template that I just created, I notice my event reciever feature is called because I have code in the ItemUpdating event that displays an error message telling users that they can not edit a survey response, this message appears when I try to create the new subsite. Should I deactivate the feature before I save the site template?
Yes. The template will also contain the definition of event receivers that are registered when you save the template. If you deactivate your feature you remove those event receiver registrations, and so your template won't contain those receiver registrations.
It's one of the awkward things about creating site templates in 2010 - you've gott pay attention to what features are active.