Where to register event handlers for a content type

Hello,
I'm developing a feature that creates site columns, content types, event receivers (class libraries) and binds all together - everything using code and not xml.  The web application should have 1 site collection and several hundreads sites. 
For example:
field1 = web.createtextfield(...); spcontenttype ct = web.createNewContenttype(...); ct.FieldLinks.Add(field1);
I have a question about binding the event receivers: Should this be done in site collection level or it should be done for every subsite?
the code is:                  
string evClass = typeof(SampleEvReceiver).FullName;string evAssembly = typeof(SampleEvReceiver).Assembly.FullName; RegisterEventHandler(currentCT, "Content Type Event Receiver", 1010, evAssembly, evClass, SPEventReceiverType.ItemUpdated); //my function.
Also, I've put the event receivers in a different project - i.e. different dll. The idea is to change the event receivers's code, copy the dll file to the gac, iisreset and have the new code running. Is this correct?
Thank you
Christos

Hi Christos,
1. This should be done in site collection level.
2. This is correct and Restart Timer Service if as need.
/Hai
Visit my blog: My Blog | Visit my forum:
SharePoint Community for Vietnamese |
Bamboo Solution Corporation

Similar Messages

  • How to remove event handlers for a content type currently in use?

    Hi,
    We had a SP 2007 solution that managed event handlers as described in
    Brian Wilson's blog regarding event handlers. We then did a in-place upgrade to SP 2010. It so happend that we wanted to remove some of our old event handlers and this is where our problem started. We managed to delete event handlers
    (SPEventReceiverDefinitions) for
    Site and List by using the ui from Brian Wilsons feature "Manage Event Handlers" (ref the link above), but not anyone at all for
    Content Types... It simply wouldn't be deleted
    (remove was grayed out in the ui). 
    We then tried to do it by code. Below is a code snippet illustrating how we tried to delete the event handlers for content types:
    using (SPWeb web = properties.Feature.Parent as SPWeb)
    string targetClassName = "targetClassName.";
    web.AllowUnsafeUpdates = true;
    // Removing Content Type event handlers
    foreach (SPContentType ct in web.ContentTypes)
    for (int i = ct.EventReceivers.Count - 1; i >= 0; i--)
    if (ct.EventReceivers[i].Class.StartsWith(targetClassName))
    ct.EventReceivers[i].Delete();
    ct.Update(true);
    web.Update();
    The Content Types are not sealed and are
    not readonly. When debugging, we can see that the
    Delete() method are called on one of the Content Types we wanted to delete event handlers for. We noted that the
    ct.EventReceivers.Count remains the same, before and after Delete() is called. We did not get any exceptions when running this code.
    When running the code a second time and debugging again, we see that the very same Content Type still has the very same event handler attached... As in, it wasn't deleted....
    We also tried to delete the event handlers through PowerShell as described
    here in the post by Per Jakobsen. However, the script did not really seem to find any EventReceivers... We tried to write the
    $site.AllWebs | % {$_.Lists} | % {$_.ContentTypes} | % {$_.EventReceivers} list to file, but it was empty.. We did however get a long list when writing $site.AllWebs | % {$_.Lists} | % {$_.ContentTypes} to file. We could then in
    that file see the event handler references we want to remove registered to our Content Types, as we did during code debugging earlier on. So PowerShell might still be the way to go here...
    So, does anyone know if there is a way to force this delete through, either by code, PowerShell or some other means? Any help regarding this matter would be very much appreciated :)

    Hi,
    For your information, there's two versions (at least) exists for each content types. One is Site Content Type - exists in Root web and another is list content type. Once you add a content type to a list, a copy of the site content type is taken and stored
    in the list. If you update the site content type, it may or may not affect the list conten type. So make sure you are updating the both - site content and list content type. Once you update site content type with passing paramater true to 'ct.Update(true)',
    the list content types are supposed to updated too.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • Event handlers for backbutton

    Hi,
    I want perform some validations when I press back button.how to find event handlers for back button,because F2
    is not giving full info for back button.
    Regards,
    Brahmaji

    Hi,
    the back button is always part of toolbar buttons.
    So you can open the view controller class and open the GET_TOOLBAR_BUTTONS method from that class.
    In this method you see how the BACK button is defined. One of the attribute of button structure is ON_CLICK.
    The value of this attribute should be the event name that is triggered when the button is clicked.
    Now open the DO_HANDLE_EVENT method from the view controller class, you will have methods with prefix EH_ON
    after the prefix you see the event name. If you find one that mached to the event name of the BACK button, then this is the event handler that is triggered by the BACK button.
    Regards,
    Steve

  • Best Practises for using Content Types

    We had third party vendor who migrated and re structured contents and sites in Sharepoint 2010. I noticed one unusual thing : In most cases they new separate site content types for every library in a site i.e. even if two libraries contain same set of metadata
    columns they created separate site content types by duplicating it from the first one and gave it unique name and used in second library.
    My point of view for content type is that they are used for re usability, i.e. if another library is needing same set of metadata columns then I would just reuse existing content type rather than creating another content type with different name by inheriting
    it from the first one and having same set of columns.
    When I asked vendor reason for this approach (for every library they created new content types and for libraries needing same set of meta data columns they just inherited from a custom site content type and created another duplicate one with same set of
    meta data columns and gave it different name in most cases name of library ) they said they did that to classify documents which I did not agree with because by creating two document libraries classification is already done.
    I need some expert advice on this, I will really appreciate: I understand content types are useful and they provide re usability but,
     A) Do we need to create new site content types whenever we create new library ? (Even though we are not going to re use them)
    B) What is best practice : if few libraries are needing same set of metadata columns
    1) Create site a content type and reuse it in those libraries ? or
    2) Create a site content type and create new content types by inheriting from site content type created at first and just give them different name even though all of them are having same set of columns  ?
    I need expert advice on this but following is my own opinion on this
    I do not think point A) is a good practice and should not be used, we should create site content type only when we think it will be re used and we do not need to create site content type every time we create document library. Also I do not think point 2)
    of B is a good practice as well
    Dhaval Raval

    It depends on the nature of the content types and the libraries. If the document types really are shared between document libraries then use the same ones. If the content types are distinct and non overlapping items that have different processes, rules or
    uses then breaking them out into a separate content type is the way forward.
    As an example for sharing content types: Teams A and B have different document libraries. Both fill in purchase orders, although they work on different projects. In this case they use the same form and sharing a content type is the no question approach.
    As an example for different content types: A company has two arms, a consultancy where they send people out to client sites and a manufacturing team who build hardware. Both need to fill in timesheets but whilst the metadata fields on both are the same the
    forms are different and/or are processed in a different manner.
    You can make a case either way, i prefer to keep the content types simple and only expand out when there's a proven need and a user base with experience with them. It means that if you wanted to subdivide later you'd have more of a headache but that's a
    risk I generally think works out.

  • HT201272 click the tab for the content type you're looking for (Music, Movies, TV Shows, Apps, or Books). No. a lie

    "From your Purchased page, click the tab for the content type you're looking for (Music, Movies, TV Shows, Apps, or Books)."
    Ok, Movies only in US.. that is fine.. BUT I only have Apps and Books to select. Where is my option to download my music again? I can see my purchases under my account but from the store trying to follow the described method - impossible!
    I don't care about apps or books.. music.. I want my paid music. No wonder people pirate music?!

    Zesty.Zooma wrote:
    But will I be able to keep the data stored in the applications, photos, books and also the sorting and the folder arrangements the same way they were, after erasing all the data and synchornizing with the new library?
    That is the aim of the process set out here: Recover your iTunes library from your iPod or iOS device.
    tt2

  • How to use custom aspx page as template for custom content type

    Hi,
    I have created custom content type and custom aspx page. I want to use aspx page as template for custom content type.
    Can anybody please let me know how to accomplish this?
    Any help would be appreciated.
    Thank you,
    AA.

    Check if you are looking for the below
    http://www.sharepointpals.com/post/How-to-Create-a-Page-Layout-(PageLayout)-with-ContentType-in-SharePoint-2013
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Workflow Status column for new content type

    Hi,
    Initially I had a document library and several workflows associated with it. After that I created a new content type inheriting Folder content type. My existing workflows could be started and work fine with any item of this new content type except anything
    related to the workflow status column, such as "Automatically update workflow status to the current stage name", or workflow action "Set workflow status". If I use the OOTB Folder content type, everything's fine. But I need custom fields
    for folder as well.
    The workflows can be started then it seems unreasonable that they are not associated with the items of the new content type, considering I set my new content type to be the child of the existing Folder content type. So why any item under this new content
    type does not have the workflow status column? I've tried removing the workflow from the list and publishing back using SPD without success.
    I also notice that when you associate a new content type to a document library/list which has some custom columns, you cannot edit those columns to be used in the new content type. You need to delete those columns and recreate them, then the option "Add
    to all content types" is there. Is this expected design?
    Thanks

    Hi,
    According to your post, an error occurred when you created a custom Edit form for new content type.
    We can do as follows:
    1.Add the MyNameSpace.MyNewEditPage dll file into GAC(C:\Windows\assembly).
    2. Execute the iisreset command.
    We can create a new content type using visual studio 2012/2013.
    http://www.sharepoint-journey.com/sharepoint-list-content-types-and-site-columns.html
    Best Regards
    Dennis Guo
    TechNet Community Support

  • OOTB Approval Workflow for a Content Type sends emails for 2 content types

    My environment: SP 2013 Server (WFE-APP) + SQL
    I have a few Content Types configured in a document library. Every content type has an OOTB approval workflow to fire an e-mail to the approver on each new/edit.
    When I create a new file for testing, it first becomes checked out with no properties added. I then edit the properties to specify its content type and other fields. When I check in the document, SharePoint sends out an e-mail to the approver for that content
    type which is correct. What SharePoint also does for this very same file is sends out an approval request e-mail for the default content type for that library which is something else than a desired content type.
    This is something I cannot understand. I thought that the workflows start on a file 'Check in'. If I check in a file that is a certain content type, why does the approval for a default content type for a library trigger as well? 

    Hi,
    Is it SharePoint 2013 workflow or previous 2010 model workflow? If it's SharePoint 2013, how are you associating workflow to content type. As per
    MSDN "Unlike previous versions, SharePoint 2013 does not support workflows that are scoped to a
    content type. However, the messaging infrastructure is extensible, so it can support
    any arbitrary scope. As a developer, you can set to", workflow association with content type (which was possible in SharePiont 2010) is no longer available out of the box. You need to do it manually, (not sure how as there's no documentation yet
    from MS) and programmatically.
    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com

  • Defining event handlers for renaming, moving, copying and deleting of files.

    Hi every one.
    I had created a tool for InDesign CS6 written using Javascript to manipulate portions of text in nested way by marking them with small non-printing small anchored text frames contains sequenced numbers and storing these portions as snippets in a spicific folder beside the InDesign documents.
    This tool is open source and free of charge, the only this that I want from you (after downloading) as a user to feedback and as a developer to improve it and join me.
    sourceforge.net/projects/livesnippets
    My question is not about this but I want to trace when the user rename, move, copy or delete a file of these snippets or any container folder and interact according to that by reserving the links between snippet files and their instances which interspersed in InDesign documents.
    Thanks.

    Here is an example of using Bridge events… What this scrript will do if you add it to Bridge scripts… is set *all* indesign snippets in the folders you browse to… to be locked/readonly… This means that users will get an extra dialog if they want to delete the file… Finder or Bridge… You can't just rename the file Finder or Bridge… and Bridge's Batch Rename will only function if the user makes copies to new location… You could set this property using the File Object with indesign…
    #target bridge
    onDocLoaded = function( event ) {
        if ( event.object instanceof Document && event.type == 'loaded' ) {
            lockIDSnippets();
            return { handled: true };
    function lockIDSnippets() {
        var i, count, doc, thum;
        doc = app.document;
        count = doc.visibleThumbnailsLength;
        for ( var i = 0; i < count; i++ ) {
            thum = doc.visibleThumbnails[i];
            if ( /\.idms/.test( thum.spec.name ) ) {
                thum.spec.readonly = true;
    // Register event handler
    app.eventHandlers.push( { handler: onDocLoaded } );

  • Multiple event handlers for one button

    I'm trying to create a button with 2 event handlers, such
    that when you roll-over the button, a submenu pops up, and when you
    click the button, you go to a certain frame. I feel like this
    shouldn't be hard at all, but it's not working. Below is the
    actionscript I have tried. Both event handlers work as I want them
    to if alone, but the on(release) functionality does not work when I
    try to put them together.(I have Flash 8). Thanks for your help!
    on (release) {
    _root.gotoAndStop("one1");
    tellTarget (_root.navigation) {
    gotoAndStop (1);
    on (rollOver) {
    this.gotoAndPlay("links");
    tellTarget (_root.navigation.introduction) {
    gotoAndStop (1);
    tellTarget (_root.navigation.overview) {
    gotoAndStop (16);
    tellTarget (_root.navigation.coronary) {
    gotoAndStop (1);

    this code is ok, it seems that when u rollover on the button,
    the event is fired and it keeps on running the time u r on it. i
    think just add
    delete this.onRollOver inside rollOver event.

  • Event Handlers for Dynamic Buttons

    Hi, I hope someone can help. I just can't figure out how to
    solve this problem:
    I am creating an number of buttons dynamically that
    correspond each to a filename read from a directory. The problem is
    I don't know ahead of time how many buttons (files) I will have so
    I create them dynamically in action script. -- this much I can do.
    What I can't figure out is how do I assign each of these
    dynamically created buttons individually specific event handlers?
    ie. I need to know which file icon you clicked on and then take
    action based on that info.
    for example: "folder" is a button icon I have linked from my
    library - i name each instance "folder"+i -- what I need to do is
    do something for folder1, folder2 etc.
    for (i=1;i<numdirs;i++) {
    graphics.attachMovie("folder","folder"+i,depth);
    graphics["folder"+i]._y= coordy2;
    // want to put an event handler here for each
    graphics["folder"+i] button
    I wanted to do something like:
    graphics["folder"+i].onRelease = function() {
    test_txt.text = i;
    but each button I click on gives me i= numdirs (ie the max
    number -- for example 6 if there are 6 files, I can't identify
    which button you actually clicked on -- button1 through 6 all
    deliver the number 6 to test_txt.text)
    I hope that makes sense - if someone can take a swag at this
    and point me in the right direction I will be very appreciative.
    Best Regards,
    Tom

    There is other way to do that.. whenever you call a
    attachMovie or loadMovie
    function there is a return value that corresponds to the
    actual movieclip
    created on the flash movie. ie
    for (i=1;i<numdirs;i++) {
    var temp_mc:MovieClip =
    graphics.attachMovie("folder","folder"+i,depth);
    that new reference temp_mc is the newly created movieclip and
    you can do
    whatever you want with it, ie:
    for (i=1;i<numdirs;i++) {
    var temp_mc:MovieClip =
    graphics.attachMovie("folder","folder"+i,depth);
    temp_mc._y = 30
    temp_mc.id = I
    //even assign new funtions to events
    temp_mc.onRelease = releaseFunction
    function releaseFunction(){
    trace("do something on the release event")
    <DIV>&quot;charmcityMD&quot;
    &lt;[email protected]&gt; wrote in
    message
    news:ed2l97$n8$[email protected]..</DIV>> THANK YOU
    soo
    much -- I have been pondering this and scanning the web for
    hours. Your
    solution is perfect. I very very much appreciate your help.
    >
    > Best Regards,
    > Tom

  • Problems when trying to return information for External Content Types in Sharepoint 2013

    This is my first post on the forum, until I tried on this problem but have not found anything.
    When trying to return the information from the external content displays the following error:
    Error retrieving data from mill. Administrators: query the server log for more information.
    I do not know what else to do...

    Hi,
    According to your post, my understanding is that you got an error when tried to return the information from the external content.
    Did the error occur when you created a new external content type or created a external list?
    You can check the steps with the following articles about how to create a external content type.
    http://lightningtools.com/bcs/creating-an-external-content-type-with-sharepoint-designer-2013/
    http://wyldesharepoint.blogspot.in/2012/12/sharepoint-2013-setting-up-external.html
    If the error occurred with the external list, you can check the steps with the following article.
    http://community.bamboosolutions.com/blogs/sharepoint-2013/archive/2013/01/08/how-to-create-external-data-column-in-sharepoint-2013.aspx
    You can also check the event log and ULS log to see if anything unexpected occurred.
    For SharePoint 2013, by default, ULS log is at      
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • View for multiple Content Type List

    Hello
    I have a SP list with multiple Content types.
    i want add a kind of view for the list that have diffrent content types for the some item/record.
    it means that every time someone edit this item and change/add diffrent data in diffrent contant type
    is there any way to do that?
    or there is a way to add the Content type dropdown list in Display view and not just in Edit view? can i do it in SP Designer?

    Hi Avinoam, do you have access to InfoPath? You can do what your asking with that program.
    cameron rautmann

  • Group by collapsed not working for external content type

    Hi,
    I've got a list that displays data from external content type and I need it to be grouped by a column and have it collapsed by default.
    The problem I have is that on a page by itself everything works fine. But when I add the list on a page with other web parts rendering the list as collapsed doesn't work as expected.
    It will render the group headers correctly and everything is collapsed. But when I expand one of the groups ALL items are shown under that group, even the ones that belong to some other group. I then expand another group and it also shows ALL items. But when
    I set the default to expanded each group header only has the items that belong to it, even if I collapse it and then expand again.
    As I said, having the groups collapsed works fine if the listview is by itself on a web part page, but as soon as I add another web part (doesn't matter what type) it stops working.
    Is this a bug or might there be something I'm doing wrong?

    Hi,
    As this issue is submitted via internal pipeline without external URL can be provided, we will keep focus on it to see if there any update.
    If there is an urgent requirement, I would suggest you call MS Customer Support Services for quick replies:
    http://support.microsoft.com/
    Best regards,
    Patrick
    Patrick Liang
    TechNet Community Support

  • Where to find the documentation for technical wage types?

    Gurus,
    I  need help finding the documentation for technical wage types such as /001...
    There are hundreds of them...
    Thanks,

    you can go to the view v_512w_d, choose your country grouping, the list of wagetypes will be displayed.
    there will be a help button available next to the wagetype name.
    you can view documentation either for technical or modal wagetypes.
    Have a good day!

Maybe you are looking for

  • Help adding new Macs to the household, creating shared drive for iTunes,

    I have a few questions: My husband and I recently both got MacBook Pros. Our former set-up was a iMac which backs up to a 500 G Time Capsule. We have a large iTunes library and iPhoto library on the iMac. The iMac is going to turn in to the kids comp

  • Delete Log File: Correspondence in Training and Event Management ( t77vp)

    Is there a standard way of deleting the Log File: Correspondence in Training and Event Management ( T77VP ) from the system. Thanks for your help. Andi

  • Javax.naming.* Not Found

    I have downloaded the j2sdkee1.3 for comiling my Ejb files.All the files get compiled but my client file which uses javax.naming package doesnt get compiled.The error message says its unable to find javax.naming package. Can somebody help me on this

  • Thunderbolt Display and MBA Display options

    if i make any application ( chrome, spotify etc ) full screen either on MBA display or on the Thunderbolt screen, the other screen goes grey. How can make an application like spotify, chrome full screen on Thunderbolt display but still keep using out

  • FDM 11.1.2.1 cannot connect to Essbase

    Hi All, I've been using FDM for a while but am new to version 11.1.2.1. When i set up my connection from the workbench i'm not able to connect to the essbase server. I keep getting a connection failed in the target dimension drop down. I've used both