Can we write an eventreceiver that gets fired when any list is updated. The listtemplateid that we have to specify for an eventreceiver makes our code specefic to one breed of lists. What if we want to have the code execute for events on all lists of site?
Select event receiver and enter the title of the event receiver. Click the Add button. Select List Item Events in the type of event receiver and select the custom list option from the event source. Then select "an item was added" in events and click Finish.
To register a remote event receiverOn the menu bar, select Project > Add New Item. In the Installed Templates pane, select the Office/SharePoint node. In the Templates pane, select the Remote Event Receiver template. In the Name box, keep the default name (RemoteEventReceiver1), and then select Add.
There are two types of Event Receiver in SharePoint, Synchronous Event Receiver. Asynchronous Event Receiver.
In an SharePoint Add-in model scenario, event receivers are created outside of SharePoint inside a web service and registered with SharePoint. These are called as Remote Event Receivers (RER). In this scenario, the event receiver code runs on the web server where the web service is hosted.
I have the same exact requirement.
Maybe it is possible to attach event receiver to System ContentType
(all content types inherit that one, with id 0x)
I`d check if that's possible by creating a Feature with a FeatureReceiver and programmatically adding it to System Content Type. Some details here.
Allright, I did some testing with console app.
EventReceiver
to System (0x). Called method ContentType.Update(true,false) which updates all child elements - nor did System ContentType
updated, nor childs. Turns out that you cannot modify those contentTypes with ReadOnly
|| Sealed
attribute set to TRUE
ContentType
. As seen from here, all ContentTypes
still inherit from that one (see ContentType hierarchy). There may be custom deployed content types that inherit from System, but not those made in GUI. Updating this content type truly updated all child ContentTypes
(all content types except those ReadOnly
or Sealed
)So a solution which would work would look like this:
Readonly
or Sealed
to false if you want those content types with you EventReceivers
.EventReceiver
to existing content types in lists (SPList.ContentTypes
)SPWeb.ContentTypes
) with id 0x01 so new lists get EventReceiver added automatically. Newly created content types will also inherit EventReceivers
. Also all subweb ContentTypes
inherit EventReceivers
.All three steps could be a console application or powershell script. Or a site-collection wide feature with FeatureReceiver
PS C:\Documents and Settings\Administrator> $web.contentTypes |ft id, name, EventReceivers, readonly, sealed
Id Name EventReceivers ReadOnly Sealed
-- ---- -------------- -------- ------
0x Sistēma {} False True
0x007F1DD730DB144C84... Darba kārtības vēsture {} True True
0x01 Ieraksts {, , , ...} False False
0x01003420C661289843... Darba kārtības ieraksts {, , , ...} False False
0x0101 Dokuments {, , , ...} False False
0x010100629D00608F81... Office datu savienoj... {} True False
0x010100B4CBD48E029A... Universālais datu sa... {} True False
0x010101 Veidlapa {, , , ...} False False
0x010102 Attēls {, , , ...} False False
0x010104 Nezināms dokumenta tips {} True False
0x010105 Lapu šablons {, , , ...} False False
0x010107 Lietotāja darbplūsma... {, , , ...} False False
0x010108 Wiki lapa {, , , ...} False False
0x010109 Pamatlapa {, , , ...} False False
0x01010901 Web daļu lapa {, , , ...} False False
0x01010A Saistīt ar dokumentu {, , , ...} False False
0x01010B Dublinas pamata kolo... {, , , ...} False False
0x0102 Notikums {, , , ...} False False
0x0103 Diskutējamais jautājums {, , , ...} False False
0x0104 Paziņojums {, , , ...} False False
0x0105 Saite {, , , ...} False False
0x0106 Kontaktpersona {, , , ...} False False
0x0107 Ziņojums {, , , ...} False False
0x0108 Uzdevums {, , , ...} False False
0x0108007122AD6D76CD... Darba kārtības uzdevums {, , , ...} False False
0x010801 Darbplūsmas uzdevums {, , , ...} False False
0x010802 Administratīvs uzdevums {, , , ...} False False
0x0109 Darbplūsmas vēsture {, , , ...} False False
0x010A Person {, , , ...} False False
0x010B SharePointGroup {, , , ...} False False
0x010C DomainGroup {, , , ...} False False
0x0110 Ziņa {, , , ...} False False
0x0111 Komentārs {, , , ...} False False
0x0116 Tālo Austrumu līgums {, , , ...} False False
0x0120 Mape {} False True
0x012001 RootOfList {} False True
0x012002 Diskusija {, , , ...} False False
Sorry, my WSS is localized, but {, , , ...} means I added several eventreceivers to content types. As you can see those with Readonly
or Sealed
attribute False are untouched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With