List item event receiver on lists in multiple webs - SharePoint 2010 - sharepoint-2010

I have multiple webs instantiated using the same template. When the web is created a custom list is created as well. Is there a way to define a global event receiver to handle to handle the ItemAdded event for all the lists defined with that template?

No, i don't think this is possible. But you can register your event receiver on the custom list within the template, and all your (newly created lists, obviously) will have the event receiver registered automatically.

Related

How to add event listeners for appointment item in outlook taskpane add in?

I have been following this example for adding event listeners but it doesn't work. Is there any way to listen when changes are made while creating an appointment in calendar (i.e. when attendees are added)?
The link I followed:
https://learn.microsoft.com/en-us/office/dev/add-ins/outlook/pinnable-taskpane#implement-the-event-handler
I need to create a taskpane that will display emails as they are added as attendees.
To listen for when attendees are added in calendar, you can register for the RecipientsChanged event. This event triggers when the recipient list of the selected item or the appointment location is changed in Outlook. Support for this event was added in requirement set 1.7. Documentation about this event can be found here. Supported events include RecurrenceChanged, RecipientsChanged, and AppointmentTimeChanged.
To add the event, you would need to call addHandlerAsync like:
Office.context.mailbox.item.addHandlerAsync(Office.EventType.RecipientsChanged, handler, callback);
where you can specify the handler and callback. Documentation for addHandlerAsync can be found here.

When should ViewModel call Service methods?

For example, there is a ViewModel that has
a collection of objects requested from a Service
an Add command to create and add new objects
a Delete command to delete selected objects
The User creates, adds and deletes objects by using corresponding commands.
How should ViewModel react on User's actions?
Should ViewModel immediately make a corresponding Service method call when the User invokes a command?
OR
Should ViewModel add / remove items from local collection, mark items as added / deleted and wait to make a Service method call only when the User invokes some Save / Apply changes button?
The second variant seems more complicated.
Does it give any performance / user experience benefit or enable any features that are not possible with the first variant?
In other words, is it better to keep ViewModel state as close to the Service / Database state as possible?

Sharepoint 2010 event receiver ItemUpdated fires twice

I attach three events to my CustomLists:
ItemAdded
ItemUpdated
ItemDeleting
On one list I have a workflow, which is changing columns in that list. So when I edit an entry in that list, the ItemUpdated-Event fires two times. On the other lists (without any workflows) my receiver is working fine.
How can I find out if a workflow called my event receiver?
Is there a difference between a workflow which fires the event, or a user who fires the event?
You can add hidden field to the list which is always sets by workflow (and only by workflow). Then you will see if workflow called the event receiver.
Or
You can create HandleEventFiring class in your workflow project and use DisableAllEventFiring and EnableAllEventFiring before and after updates in workflow
public class HandleEventFiring : SPItemEventReceiver
{
public void DisableAllEventFiring()
{
this.DisableEventFiring();
}
public void EnableAllEventFiring()
{
this.EnableEventFiring();
}
}
To answer your first question:
Yes, you can find your workflow. The easiest way would be to use the SharePointManager 2010 and
Navigate to your site collection is located
Lists -> [Your List] -> Event Receivers
Check each Event Receiver's properties and delete the event receiver that is firing twice.
I don't know if I understand your second question correctly, but here goes:
A workflow can be started manually by a user or automatically if a List Item is
Added
Updated or
Deleted
Other than that there is not much of a differance.

Custom List Template is not being pulled by SPSite.GetCustomListTemplates()

I am adding custom lists programmaticaly from a custom template. I check to see if the custom list template exists, and if not I create the list template by creating a list and then saving it as a template using the SPList.SaveAsTemplate() method. However, during the same timer job, I try to get the list template, but it doesn't show in the SPSite.GetCustomListTemplates() method. It does however show in the UI under the List Template Gallery. Any idea as to why it would show in the UI but not be returned in the method call?
Read my answer to this question. With that you should get a result from GetCustomListTemplates instead of just an empty list.

Reloading control

I have created a custom control which I am using multiple times on the page.
I checked value at the Loaded event.
Due to long delay of data retrieval, I am not able to check value at the control loaded event.
Now I need to reload the control after data retrieval from the WCF service.
Can you please suggest me the right approach to do the same.
Thank you.
If you are using Silverlight to call a WCF service to get your data, you will be working Asynchronous right?
You could hook up the completed event of your webservice call to do anything (like reloading, rebinding your controls) you want after the data has been retrieved from your WCF service.
It would be better if you could set up binding to your custom control. Whenever the observable data is retrieved and assigned to your binding object, your control will be updated.