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

Similar Messages

  • 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

  • How to remove the '#'symbols for infoobject movement types in bex reporting

    Hi All,
      I have a problem in Bex reporting. The problem is when ever executing the report  that time some of the characteristic values is shown in layout '#' Symbols. i want to remove the '#' valuse in report.
    is it possible please give me step by step procedure for how to remove the '#' Symbols in reporing layout.
    this is very urgent please help to me on this issue.
    Thanks & Regards,
    Guna.

    Hi Guna,
    To achieve this issue, we need to replace the value of ‘#’, we need to change the description while retrieving the data from tables. So we need to write some ABAP code in SE38. Go to RSA1 transaction and go to Info objects tab. Then go to context menu for ‘cProject Key Figures’ as shown below. Click on the ‘Object Overview’ to get the overview of all the info objects. Here you can see the field names which are used to know the table names.
    In SE11, type the table name in ‘Database Table’ field. Now press ‘F4’, then you will get the next screen to select one of the P/Q/S/T tables.
    Now click on the button rounded in the below screen to view the data in the table.
    Now click the execute button or press ‘F8’ to view the records.
    Now go to Tcode: SE38. Create a source code and give some program name for that source code. To write code, you need access key. Contact your BASIS for this.
    Now write the below code for that particular table in which you want to change the value ‘#’ to description ‘Blank’. In the below source code, we are updating particular table, setting the field as ‘Blank’ where it is null or no value. Here the field will automatically get updated to ‘#’ if there is no value or null.
    update /BIC/PXXXXX set /BIC/ZXXXX = 'Blank' where /BIC/ZXXXXX is null or /BIC/ZXXXX = ''.
    if sy-subrc eq 0.
    write 'successful'.
    commit work.
    else.
    write 'unsuccessful'.
    endif.
    OR
    If this # is because of the missing master data than,
    right click that IO -> maintain master
    you will see first row as a blank.
    whatever value you maintain in this row that will come in the report for all Not assigned # values of the master data in the report.
    maintain it according to your requirement, save and activate the master data
    Hope this helps u...
    Regards,
    KK.

  • How to remove multiple instances of a content type (jpeg) in Options/Applications?

    Want to save a JPEG on email messages however am not receiving the "Open or Save File" option when clicking on download. When checking the Options/Applications/Content Type list, JPEG Image appears twice and the Action for one of those cannot be changed. Thought removing one of these Content Types might resolved the problem, however it cannot be removed, at least without further instructions for doing such.

    hello, maybe the file which holds the download actions became corrupted. please try the following: go to the
    * firefox ''menu [[Image:New Fx Menu]] > help [[Image:Help-29]] > troubleshooting information'',
    click on ''profile folder/show folder'' and close all firefox windows afterwards. a windows explorer window should open up - in there rename or delete the file named '''mimetypes.rdf''' - it will be regenerated again the next time you launch the browser.

  • 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

  • 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

  • How to remove payment block for AP invoices which has been cleared

    How to remove payment block for AP invoices which has been cleared
    Thanks
    Chiru

    Hi,
    Thanks for immediate response in fb02 is in deable mode
    mrbr unable to change
    please provide to to remove blocking code i will assign points
    Thnaks
    Chiru

  • How to remove leading zeros for an item number within quickviewer

    how to remove leading zeros for an item number within quickviewer. Pls help

    ask your abap guy to do  it. not portal guys business.

  • HT1349 how to remove apple id for imessage

    how to remove apple id for imessage

    Go to Settings>Messages>Receive At...tap the Apple ID at the top, sign out.

  • 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

  • How to know whether the Content Type at Library level is Inheriting Parent Content type or not Using Powershell?

    Hi,
    How to know whether the Content Type at Library level is Inheriting Parent Content type or not using Powershell?
    Is there any property for that? Or Do I need to compare the Content type Id's at Site collection level and Library level?
    Any help would be greatly appreciated.
    Thank you,
    AA.

    Hi Ashok,
    For a content type, there is an attribute called Inherits, the value of this attribute determines whether the content type inherits fields from its parent content type when it is created.
    If Inherits is TRUE, the child content type inherits all fields that are in the parent, including fields that users have added.
    If Inherits is FALSE or absent and the parent content type is a built-in type, the child content type inherits only the fields that were in the parent content type when SharePoint Foundation was
    installed. The child content type does not have any fields that users have added to the parent content type.
    More information, please refer to the link:
    https://msdn.microsoft.com/en-us/library/office/aa544268.aspx?f=255&MSPPError=-2147217396
    Best Regards,
    Wendy
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • 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

  • How to Keep Content Types Current with Updated Data

    Let’s say that I have four content types—content type 1, content type 2, content type 3, and content type 4—all based on the same list, say list A.
    Each content type has its own workflow.
    When the workflow for content type 1 is completed, the data is saved to an individual item, say item Z, in a separate list, list B.
    When the workflow for content type 2 is completed, the data is saved to the same item (item Z) in list B. The reason that there are two lists is that the creation of content types causes new items to be created, but the each
    new item must reference data from the previous item. That means that data has to be copied from the first item to the second item. But what happens to the data in the second item when data from the first item is changed? The solution is to have a single item
    in another list to which all content types write their data.
    What I need to know is how can all the content types retrieve data from list B when those content types are based on list A? For example, let's say that content type 3 uses data originally input through content type 1. As the
    user inputs and saves data through content type 3 he sees data that had been originally input through content type 1. Another user then accesses content type 1 to update and save data through it. When content type 3 is opened again that user will not see the
    updated data entered through content type 1 because it is tied to a different item. The solution seems to be for all content types to save their data to the same item in another list. But then how can those content types be designed so that when they open
    they show updated data from List B when those content types are based on List A?
    Other applications have the notion of a folder containing all the up-to-date data fields. Another way to look at this problem is to state what SharePoint 2007 does to mimic the notion of a folder.

    Thanks for responding, but I don't think that the solution provided solves my problem. What you described will keep the item in List B in sync with the changes made to List A. However, the content types from List A will not be in sync when they are opened
    from List A. Say content type 1 makes changes to various fields. When content type 3 opens it displays some of the fields that content type 1 changed; however, content type 3 and content type 1 by definition display different items--and those items are not
    in sync. Either I have to copy the updated item from List B back to the related items in List A or there has to be another solution.
    Is it possible to have a workflow update all the items in a list based on a key field whenever changes are made to that item. Say content types 1, 2, 3, and 4 already exist and each refers to a different item in List A, but they are "tied" together
    by a key field. When content type 1 is reopened and changes are made, is it possible to iterate over the items in a list to find other items whose key field matches the key field from content type 1? If so, then when matching items are found the fields in
    them can be updated by the same changes made to content type 1.
    If this latter scenario is possible, how is that iteration set up in a SharePoint 2007 workflow? Thanks again.

  • How to create a macro for a planning type in MC8b transaction

    Hi,
    I am presently working for a product allocation demand, which have a information structiure with characteristic and key field.
    the characteristic are production allocation quantity, incoming order quantity, and open order quantity.
    i have created a planning type in which the data updation takes from the excel file to the planning type in mc95.
    but i need to create a macro for this planning type .
    can any body give the details information how to create a Macro for a planning type.
    Thanks and regards
    GopalKrishna

    Dear Gopal
    May be the link would be helpful to you.
    [Planning Types and Macros|http://help.sap.com/saphelp_46c/helpdata/en/a5/631cc443a211d189410000e829fbbd/frameset.htm]
    Drill down the left tab once you opened the link, for more information.
    Thanks
    G. Lakshmipathi

  • HT1688 how to do factory unlock for my  iphone4? Now i use another country carrier so please tell me how to do that .

    how to do factory unlock for my  iphone4? Now i use another country carrier so please tell me how to do that .

    how to do please explain me . i live from myanmar so this case is difficult and i don`t know original cellular provider

Maybe you are looking for

  • Ipod 4th gen Win XP needs a mass storage driver but can't find one

    Hi Guys, Just got a new PC, Ipod Was fine on my old one. However under Win XP, Ipod update and Itunes all installed correctly, but XP keeps asking for a MAss Storage driver. Tried alsorts of things including reinstallation of all iPod Software, but s

  • How to get the current date in a workflow

    Hey, Can anyone tell me how to get the current date while in a workflow? Thanks in advance.

  • Problem with WS14000075

    Workflow Without Approval for PurchOrder is active and when i create a PO, it will be in status awaiting for approval for ever. When looked at the approvals, gives me a message approval not required. Looked at the threads checked SWETYPV, SWDS, SWUS

  • I am not able to execute the transport.send(message)

    I am not able to execute the transport.send(message) when trying for sending mail. I am getting error like this : - javax.mail.SendFailedException: Sending failed;  nested exception is: javax.mail.MessagingException: Could not connect to SMTP host: 1

  • OER Atrifacts Store Setup and Configuration for CVS.

    Hello, My question is related to proper configuration of a CVS based Artifact Store in Oracle Enterprise Repository. I've attempted to configure a CVS Artifact Store from within OER's Asset Editor (as described on page 27 of the OER Configuration Gui