Unable to update available content types on SPContentType.Name

Updating content type.name property does not reflect in web.Availablecontenttypes.
                                    cTypeToBeModified.Name = "IXT_D";
                                    cTypeToBeModified.UpdateIncludingSealedAndReadOnly(true);//since content type is read only
                                    web.Update();
This is specific to Chinese traditional environment -
- English Win2k8 Std R2
- Traditional Chinese MUI deployed
- English SQL 2008,
- CHT SP 2010 Server STD SP2
Any ideas on this?
shwetank

Hi,
I did a test with the code below and it works properly, please refer:
SPSite site = new SPSite("http://sp/sites/mysite");
SPWeb web = site.OpenWeb();
SPContentTypeId id = new SPContentTypeId("0x0104");
SPContentType type = web.ContentTypes[id];
type.Name = "Announcement2";
type.Update();
Console.Write(web.AvailableContentTypes[id].Name);
More information about Update method of SPContentType for your reference:
http://msdn.microsoft.com/en-us/library/ms472234.aspx
Feel free to reply with the test result if the issue still exists.
Best regards
Patrick Liang
TechNet Community Support

Similar Messages

  • Update registered content types

    When trying to update a registered content type, programatically, the update fails with an SQL exception, warning of a certain constraint in database.
    However, this problem only occurs if connection pools reside on an MS SQL server. On MySQL for example, update goes fine.
    Does anyone have an idea how to make it work on MS SQL?

    Can you post the code you are using, and the exception trace you are seeing?

  • Unable to update webpage contents

    Whenever I try to use "put" and "synchronyse" commands to update my nouridjanianpsychologicaltesting.com pages, webpage content still remains unupdated and unchanged, even when I used Insert>Template>Update Pages commands. I use FTP server mode and also unable to engage server behavior, such as use Recordset option, as RDS log-in is unavailable in FTP regime. Please, help me solve these persistent and unaccounted for problems of updating webpages in FTP regime and enabling Recordset option in FTP regime. I use Windows Vista and receive error messages about non-working Cold Fusion in FTP environment, when I try to engage Recordset option in vain. I will sue Adobe.com in federal downtown court, if you fail to help me solve this persistent problem, as I paid 400$ for this Creative Suite CS4, and all I get are unsolved problems with FTP environment. I do rely on your ability to troubleshoot webpage updating problem in FTP environment and inablity to use record sets and other other server behaviors. When I checked Dreamweaver manual to troubleshoot these problems, no direct answers were revealed by the Adobe manual. I am desperate to get your urgent help now!
                     Your dear and loyal customer Armenak Nouridjanian.

    Sorry, Nourid, you are not understanding something here: This is a user-to-user forum and you cannot hold anyone responsible for the tips they offer or for not having any clue about your specific problem. If you must have official support, please create a support case using the customers support form and don't go off aaccusing the wrong people. Specific to your issue: Have you considered, that this may actually be a problem with your hoster's virtual directory structure and utterly unrelated to DW? Your files definitely are going somewhere on your server, but that doesn't seem to be your home directory...
    Mylenium

  • Unable to update availability in calendar

    When i try to update the availability or the reminder I cannot exit that screen

    On your Mac open System Preferences > iCloud
    Deselect the box next to:  Calendars & Reminders then reselect it.
    On your iPhone, tap Settings > Calendars
    Switch Calendars off then back on.
    Give iCloud a few minutes to re sync the data and try adding an event in the Calendar.

  • ? Unable to update adobe content viewer for desktop.

    To Dps Users,
    Having downloaded the new adobe content viewer 2.3.1 through itunes and installed it onto my ipad. I now find I cannot update the desktop version this still remains at 2.3.0
    anyone any advise how to get the most current version onto my laptop.
    Regards
    Vividi

    The desktop version doesn’t need to be updated.
    Bob

  • Content Types updates not getting pushed to Lists/Libraries Sharepoint 2013

    Hello,
    We have updated Content Type at Content Type Hub(ex. Making columns Hidden/Req...etc..). These changes are pushed to the consumer sites site level Content types but the problem is these changes are not reflecting at List/Library level Content type.
    Is there a way to explicitly push down the changes ?
    Best Regards, Pankaj Rana

    http://sharepoint.stackexchange.com/questions/52259/how-to-update-a-deployed-content-type
    perform the changes to the ContentType make sure to push changes to the lists while updating the ContentType.
    For now, you might need to perform some clean-up job here, just to make sure the field is deleted from all the lists, with your Custom ContentType. Use the following PowerShell script for clean-up! Vårsegod :)
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    $site = Get-SPSite "http://your.site.com"
    foreach($web in $site.AllWebs)
    #iterates through all the Lists
    for ($i = 0; $i -lt $web.Lists.Count; $i++)
    $list = $web.Lists[$i];
    $MyListContentTypes = $list.ContentTypes
    if ($MyListContentTypes -ne $null)
    $ct = $list.ContentTypes["You Desired Content Type Name"]
    if($ct)
    Write-Host "In list Content Type and deleting the field" $ct.Fields["You Field Name"].Id;
    $ct.FieldLinks.Delete($ct.Fields["You Field Name"].Id)
    $ct.Update()
    Edit: How to push down changes to all the Content types via SharePoint Server Object Model:
    using (SPWeb oWebsite = new SPSite("http://MyServer/sites/MySiteCollection/MyWebSite").OpenWeb())
    SPList oList = oWebsite.GetList("MyWebSite/Lists/MyList");
    SPFieldCollection collFields = oWebsite.Fields;
    string strNewColumn = collFields.Add("MyNewColumn", SPFieldType.Text, false);
    SPFieldLink oFieldLink = new SPFieldLink(fields[strNewColumn]);
    SPContentType oContentType = oList.ContentTypes["Specification"];
    oContentType.FieldLinks.Add(oFieldLink);
    oContentType.Update(true);
    Edit 2: Update a Content Type using PowerShell:
    Add-PSSnapin Microsoft.SharePoint.PowerShell -erroraction SilentlyContinue
    //get the specific Root web
    $spweb= Get-SPWeb "http://your.site.com"
    //get the fields collection
    $fields = $spWeb.Fields
    //get the specific field
    $field = $fields.GetFieldByInternalName("Name of you field")
    //get the specific Content Types from Root Web
    $contentType = $spWeb.ContentTypes["You Content Type"]
    //delete a field from a Content Type
    $contentType.FieldLinks.Delete($field)
    //add a field to a Content Type
    $contentType.FieldLinks.Add($field)
    //update the Content Type and push changes to the children
    $contentType.Update($true)http://sharepoint.stackexchange.com/questions/42744/how-to-add-a-field-to-a-contenttype-with-feature-upgrade-for-new-and-existing-shttp://msdn.microsoft.com/en-us/library/office/aa543504%28v=office.14%29.aspx
    If this helped you resolve your issue, please mark it Answered

  • Update content type definition in sandboxed solution

    In my web application I am using a content type hub. The content type hub contains a sandboxed solution which contains several content type and column definitions like this:
    <ContentType>
    <FieldRefs>
    <FieldRef ID="" Name="" />
    </FieldRefs>
    </ContentType>
    <Field ID="" Name="" />
    Now I need to update a content type definition by adding a new column. In my content type definition in Visual Studio I added the field refence to the column and build a new WSP.
    I am updating the sandboxed solution with PowerShell. First I add the new solution:
    Add-SPUserSolution -Site $url -LiteralPath $newSolutionFile
    Then I update the old solution with the new:
    Update-SPUserSolution -Identity $oldSolutionName -Site $url -ToSolution $newSolutionName
    The old solution is deactivated and the new solution is activated, so the update did go well. But when I go to see the content type, it's not updated. The newly added column did not get added.
    When I manually deactivate the newly added sandboxed solution and activate it straight away the content type does get updated. So it looks like the Update-SPUserSolution command does not update the content type and column definitions.
    Does anyone has experience with updating content types with the Update-SPUserSolution command?

    Hi,
    Please check the link below.
    http://msdn.microsoft.com/en-in/library/ff798382.aspx.
     you can use the Update-SPUserSolution command
    in Windows PowerShell to upgrade your solutions. However, this requires access to the server environment, which is not necessarily available to sandboxed solution developers or site collection administrators.
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Incorrect Infopath content type update in form library after modifying Infopath form and publish it

    I have an admin approved InfoPath form. I added new fields to that form and mapped those new fields with site columns. After uploading updated published form through CA, I noticed InfoPath Site content type for that form got updated (with newly added fields)
    under Microsoft_Infopath group. This content type is also added in form library but somehow the new fields are updated incorrectly for this content type existing in form library (it doesn't show new fields, and shows one new field which is incorrectly
    mapped with other column this is happening only in library). 
    Things I tried:
    - Activate/Deactivate that content type feature
    - Deactivated feature, removed form from CA, re uploaded and activated feature
    - Removed those new fields and published and uploaded InfoPath form and then added those new fields and published and uploaded again.
    -Deleted those fields from InfoPath and readded new fields and published and uploaded form but still the problem persists.
    Any help will be appreciated.
    Dhaval Raval

    Hi Thanks for the response,
    But Update all content types inheriting from this type is already checked.
    That form library has multiple content types associated with it , different infopath forms get submitted there. What I noticed is that when I change the form and publish it, its corresponding site content type gets updated but the same content type used
    in form library doesn't get updated properly. I went to form library and checked that erroneous content type, there were some columns missing and one column was mapped incorrectly. When I clicked on "Parent" content type, it was showing all the new Infopath
    fields(updated content type). So I figured that Infopath site content type was getting updated correctly but it was not able to propagate those updates (in a correct way) to the form library. I also tried to edit that content type and tried adding existing
    site columns which were missing but surprisingly it was not showing those site columns either, which were mapped from Infopath publishing.
    The cause for this behavior is : changes/updates to the Infopath content type are not getting propagated to the form library and this is happening for only one infopath content type but other Infopath content types are getting updated.
    I had to delete all the forms using that erroneous content type and then had to delete that content type from the library and then re-added that Infopath content type to the library and this time it was having correct content type (updated columns).
    This is not a perfect solution for the production environment, sounds like it is a bug.
    Dhaval Raval

  • Update content type in list not working

    My list content type is not getting updated.
    I have a content type defined in a feature. I have created a new column and updated the feature definition and reactivated the feature.  I have also written powershell to check and update the content type with the new column.  The content type
    gets updated but not at the list level.  The powershell looks like this:
    Function UpdateContentType($contentType, $fieldLink)
    if ($contentType.FieldLinks[$fieldLink.Name] -eq $null)
    Write-Host Adding Field to content type
    $contentType.FieldLinks.Add($fieldLink)
    $contentType.Update($true)
    I thought the Update method was supposed to push the changes down, but it doesn't seem to be working.  This code does work in a different environment so I'm not what is going on.
    Caroline

    You will need to updated the list also, after updating the content type
    This is sample code how you update list which is using the Content Type.
    IList<SPContentTypeUsage> usage = SPContentTypeUsage.GetUsages(newsCT);
    foreach (SPContentTypeUsage item in usage)
    if (item.IsUrlToList)
    SPList list = rootWeb.GetList(item.Url);
    if (!list.Fields.ContainsField(firstName.InternalName))
    list.Fields.Add(firstName);
    list.Update();
    more information you can check at this link
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Unable to add sitecolumn to content type.

    I have added a sitecolumn to content type through visual studio and deployed it and it got added.When i try to add one more column to content type and deploy it its not getting added..Please can i know if there is any solution for upgrading this content
    type without using feature activation code.

    try these links:
    http://sharepoint.stackexchange.com/questions/11114/how-to-delete-a-content-type-part-of-an-application-feature
    http://stackoverflow.com/questions/6427315/unable-to-delete-sharepoint-2010-contenttype-contenty-type-in-use
    https://social.technet.microsoft.com/forums/sharepoint/en-US/b859be4f-afb1-46b2-b5da-bb88cff9a1d1/unable-to-delete-the-content-type
    https://msdn.microsoft.com/en-us/library/office/ms453791%28v=office.14%29.aspx
    http://stackoverflow.com/questions/4963309/content-type-cant-be-deletedtry deleting content type and recreating it again.
    Please mark it as answer if you find it useful happy sharepointing

  • A content type failed to be syndicated: Microsoft.SharePoint.SPContentTypeReadOnlyException

    I've got a content type hub in my SharePoint 2010 environment. I've updated a content type on the hub and now when the timer job for the content type hub runs I'm getting a lot of messages like this one:
    A content type failed to be syndicated: Microsoft.SharePoint.SPContentTypeReadOnlyException: The content type "Site Request"
    at "/sites/sitename" is read only.   
    at Microsoft.SharePoint.SPContentType.Update(Boolean updateChildren, Boolean ignoreSealedOrReadOnly, Boolean throwOnSealedOrReadOnly, IList`1 exceptions)   
    at Microsoft.SharePoint.SPContentType.Update()   
    at Microsoft.SharePoint.Taxonomy.ContentTypeSync.Internal.SubscriberImport.UnshareContentType(SPContentType contentType, Boolean previousReadOnlyValue)   
    at Microsoft.SharePoint.Taxonomy.ContentTypeSync.Internal.SubscriberImport.UnshareContentType(String contentTypeIdString)   
    at Microsoft.SharePoint.Taxonomy.ContentTypeSync.Internal.Subscriber.SynchronizeSite(TaxonomySession session, TermStore termStore, MetadataWebServiceApplicationProxy proxy, SPSite site, Guid rawPartitionId, DownloadedHubData downloadedHubData, SyndicationResult
    result, SiteStatus& siteStatus)
    There haven't been any updates made to the content types for quite a while. So this issue might have occurred since the latest SharePoint updates were installed.
    To me it sounds like this could be a permission issue but I can't see an issue with the permissions.

    Hi Pieter,
    Thanks for the sharing the information.
    Regards,
    Rebecca Tu
    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]

  • 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

  • Error while updating the content in workflow

    Hi,
    I'm getting an error while updating the content in workflow thru the checkout option. i.e. contributor checks in the content - reviewer rejects the content - then contributor checks out and modifies the content as per the reviewer's remarks and while checking in the following error occurs
    Content Server Request Failed
    Unable to check in content item 'HO000128' for workflow. Unable to execute service method 'checkInUpdateRevByID'. (System Error: Runtime error: java.lang.NullPointerException
    at intradoc.server.DocServiceHandler.checkInRevByID(DocServiceHandler.java:248)
    at intradoc.server.DocServiceHandler.checkInUpdateRevByID(DocServiceHandler.java:240)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)
    at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)
    at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)
    at intradoc.server.Service.doCodeEx(Service.java:490)
    at intradoc.server.Service.doCode(Service.java:472)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)
    at intradoc.server.Service.doAction(Service.java:452)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeSubServiceCode(ServiceRequestImplementor.java:1071)
    at intradoc.server.Service.executeSubServiceCode(Service.java:3497)
    at intradoc.server.ServiceRequestImplementor.executeServiceEx(ServiceRequestImplementor.java:942)
    at intradoc.server.Service.executeServiceEx(Service.java:3492)
    at intradoc.server.Service.executeService(Service.java:3476)
    at intradoc.server.DocServiceHandler.determineWorkflowCheckin(DocServiceHandler.java:3833)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)
    at intradoc.common.ClassHelperUtils.executeMethodReportStatus(ClassHelperUtils.java:293)
    at intradoc.server.ServiceHandler.executeAction(ServiceHandler.java:79)
    at intradoc.server.Service.doCodeEx(Service.java:490)
    at intradoc.server.Service.doCode(Service.java:472)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)
    at intradoc.server.Service.doAction(Service.java:452)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeSubServiceCode(ServiceRequestImplementor.java:1071)
    at intradoc.server.Service.executeSubServiceCode(Service.java:3497)
    at intradoc.server.ServiceRequestImplementor.executeServiceEx(ServiceRequestImplementor.java:942)
    at intradoc.server.Service.executeServiceEx(Service.java:3492)
    at intradoc.server.Service.executeService(Service.java:3476)
    at intradoc.server.Service.doSubService(Service.java:3465)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at intradoc.common.IdcMethodHolder.invokeMethod(ClassHelperUtils.java:617)
    at intradoc.common.ClassHelperUtils.executeMethodEx(ClassHelperUtils.java:279)
    at intradoc.common.ClassHelperUtils.executeMethod(ClassHelperUtils.java:264)
    at intradoc.server.Service.doCodeEx(Service.java:507)
    at intradoc.server.Service.doCode(Service.java:472)
    at intradoc.server.ServiceRequestImplementor.doAction(ServiceRequestImplementor.java:1360)
    at intradoc.server.Service.doAction(Service.java:452)
    at intradoc.server.ServiceRequestImplementor.doActions(ServiceRequestImplementor.java:1201)
    at intradoc.server.Service.doActions(Service.java:447)
    at intradoc.server.ServiceRequestImplementor.executeActions(ServiceRequestImplementor.java:1121)
    at intradoc.server.Service.executeActions(Service.java:433)
    at intradoc.server.ServiceRequestImplementor.doRequest(ServiceRequestImplementor.java:635)
    at intradoc.server.Service.doRequest(Service.java:1707)
    at intradoc.server.ServiceManager.processCommand(ServiceManager.java:359)
    at intradoc.server.IdcServerThread.run(IdcServerThread.java:197))
    Please help to resolve.
    Thanks in advance
    Prasad

    I also get error while updating the content in workflow thru the checkout option as reviewer. i.e. contributor checks in the content - then reviewer either updates the metadata or checks out and modifies the content and while checking in the following error occurs
    Content Server Request Failed
    Unable to update the content item information for 'HO000128'.
    The content ID must be specified.
    Please help to resolve.
    Thanks in advance
    Prasad

  • Deploying a Reusable Workflow to a List Content Type using PowerShell

    We have a situation where deployment of a reusable workflow for a site content type cannot be completed through the web interface due to the number of libraries where the content type is in use (time-out on deploy and update).
    It was hoped that this could be accomplished with PowerShell but the method of deploying to a list content type appears to be different than it is to a list (all content types).
    The below snippet works fine for a list / all content types:
    function AddWorkflowToLibraries ($SiteCollection, $ctName, $WfName, $WfAssociationName)
    $site = Get-SPSite $SiteCollection
    [Guid]$wfTemplateId = New-Object Guid
    #Step through each web in site collection
    $site | Get-SPWeb -limit all | ForEach-Object {
    $web = $_
    $_.Lists | ForEach-Object{
    if($_.AllowContentTypes -eq $true)
    if($_.ContentTypes.Item("$ctName") -ne $null)
    write-host "Enabling workflow on" $_.Title "in" $_.ParentWebUrl
    $ct = $_.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = "Tasks"
    $historylist = "Workflow History"
    if(!$web.Lists[$historylist])
    $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site. It is created by the Publishing feature.",
    "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
    if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
    Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
    $wfHistory = $web.Lists[$historylist]
    $wfHistory.Hidden = $true
    $wfHistory.Update()
    if(!$web.Lists[$tasklist])
    $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.AddWorkflowAssociation($association)
    $_.Update()
    else
    Write-Error "Workflow Template not found"
    AddWorkflowToLibraries <Site Name> <Content Type Name> <Workflow Template Name> <Association Name>
    However changing the association as follows causes the script to still execute without a problem but the workflow doesn't appear for the content and the associations collection is empty:
    function AddWorkflowToLibraries ($SiteCollection, $ctName, $WfName, $WfAssociationName)
    $site = Get-SPSite $SiteCollection
    [Guid]$wfTemplateId = New-Object Guid
    #Step through each web in site collection
    $site | Get-SPWeb -limit all | ForEach-Object {
    $web = $_
    $_.Lists | ForEach-Object{
    if($_.AllowContentTypes -eq $true)
    if($_.ContentTypes.Item("$ctName") -ne $null)
    write-host "Enabling workflow on" $_.Title "in" $_.ParentWebUrl
    $ct = $_.ContentTypes[$ctName]
    $culture = New-Object System.Globalization.CultureInfo("en-US")
    $template = $site.RootWeb.WorkflowTemplates.GetTemplateByName($WfName, $culture)
    if($template -ne $null)
    $tasklist = "Tasks"
    $historylist = "Workflow History"
    if(!$web.Lists[$historylist])
    $web.Lists.Add($historylist, "A system library used to store workflow history information that is created in this site. It is created by the Publishing feature.",
    "WorkflowHistory", "00BFEA71-4EA5-48D4-A4AD-305CF7030140", 140, "100")
    if (!$web.Features["00BFEA71-4EA5-48D4-A4AD-305CF7030140"]) {
    Enable-SPFeature -Identity WorkflowHistoryList -Url $web.Url
    $wfHistory = $web.Lists[$historylist]
    $wfHistory.Hidden = $true
    $wfHistory.Update()
    if(!$web.Lists[$tasklist])
    $web.Lists.Add($tasklist, "This system library was created by the Publishing feature to store workflow tasks that are created in this site.", "WorkflowTasks", "00BFEA71-A83E-497E-9BA0-7A5C597D0107", 107, "100")
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.ContentTypes[$ctname].AddWorkflowAssociation($association)
    $_.ContentTypes[$ctname].Update()
    else
    Write-Error "Workflow Template not found"
    AddWorkflowToLibraries <Site Name> <Content Type Name> <Workflow Template Name> <Association Name>
    The only change is:
    $association = [Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($template, $wfName, $web.Lists[$tasklist], $web.Lists[$historylist])
    $association.AllowManual = $true
    $_.ContentTypes[$ctname].AddWorkflowAssociation($association)
    $_.ContentTypes[$ctname].Update()
    But unlike the list version, the association doesn't appear to be saved and no error is generated.
    Is anyone aware of what may cause this or have an example in C# that may explain something my script is missing?

    Hi Garry,
    After you associate the workflow to the content type, you should update the update the content type using
    $ct.UpdateWorkflowAssociationsOnChildren($true,$true,$true,$false)
     method.
    Here is the completed script:
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    $site=Get-SPSite "http://serverName"
    $web=$site.OpenWeb()
    $list=$web.Lists["ListC"]
    $taskList=$web.Lists["Tasks"]
    $historyList=$web.Lists["Workflow History"]
    $ct=$list.ContentTypes["Link"]
    $culture=New-Object System.Globalization.CultureInfo("en-US")
    $wfTemplate=$web.WorkflowTemplates.GetTemplateByName("Three-State",$culture)
    $associationWF=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($wfTemplate, "myThreeStateWF",$taskList,$historyList)
    $ct.WorkflowAssociations.Add($associationWF)
    $ct.UpdateWorkflowAssociationsOnChildren($true,$true,$true,$false)
    Here is a demo about how to update it using C#
    http://www.thorntontechnical.com/tech/sharepoint/sharepoint-2010-associate-workflow-to-content-type-in-a-feature
    Wayne Fan
    TechNet Community Support

  • Can't find content type?

    First off, I just want to thank the people that take time out of their day to answer questions on this, or any forum for that matter. You people empower thousands of others with your knowledge.  
    I'm working in code behind for a custom edit list form, trying to get a custom content type I created in this solution to create a new document set off of. Both my custom list and my custom document set content types show up in site settings, but in code
    I can't find the custom document set content type. 
    SPContentType documentSetCT = currentWeb.ContentTypes["Document Set"]; //gets OOB "Document Set" content type
    SPContentType customListCT = currentWeb.ContentTypes["CustomList"]; //gets my custom content type based off Item
    SPContentType customDocumentSetCT = currentWeb.ContentTypes["customDocumentSet"]; //Finds nothing
    Thoughts? What am I doing wrong here?
    - Daniel

    Hi,
    Does this custom content type appear in the “Site Settings”->”Site Content Types” page?
    I suggest you retrieve all the content types programmatically to check whether your custom one exists.
    The code below will retrieve all the content types for your reference:
    using (SPSite site = new SPSite("http://sp"))
    using (SPWeb web = site.RootWeb)
    SPContentTypeCollection cts = web.ContentTypes;
    foreach (SPContentType ct in cts)
    Console.WriteLine(ct.Name);
    Feel free to reply if the issue still exists.
    Best regards
    Patrick Liang
    TechNet Community Support

Maybe you are looking for

  • R12.1.2/11.1.0.7 PO Import extremely Slow

    Hi All We are struggling with performance on a 100,000 PO import using POXPOPDOI (Standard Purchase Order Import program) on R12.1.2 and 11.1.0.7 (HP-UX 16GB 2 x Intel(R) Itanium 2 9100 series processors (1.67 GHz, 18 MB) B.11.31. I know it's a lot o

  • Adapter JNDI are errored out in JNDI tree on Weblogic

    Hey, I have setup weblogic 10.3.4 and SOA Suite 11g. The adapters seem to be deployed and active with a green 'OK' status in the deployments on the soa_server1. However when I go to the jndi tree for the soa_server1, all the adapters have an '!' for

  • Error, Error, Error

    I used to get "error 8" frequently, but now I receive "error 22" when trying to video chat with my girlfriend. I have browsed these forums frequently, trying every suggestion I have come across, but no help anywhere has fixed my problem. She is using

  • Tables relevant to MRP, MD04  tcode and stock related tcodes

    Hello gurus,              table related to STOCK, MRP, AVAILAIBILYT CHECK AND TOR, MD04 Tcode Thanks in advance Sameer

  • Unable to check registry for Visual C++ 2008 redistributables using WIX Bootsraper

    I am able to check registry for Visual C++ 2010 redistributables using WIX Bootsrapper using below code util:RegistrySearch Id="VC2010x86" Root="HKLM" Key="SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86" Variable="CPP2010Redistx86" Value="Insta