Limitations on modifying content types via SharePoint Designer reusable workflows

Man's hand tied  limitation with a rope. On a white background.If you’ve read my blog post on using content types to modify your NewForm.aspx and EditForm.aspx pages, you know how fond I am of using SharePoint Designer workflows to flip the values in my Content Type fields. Since content types control which fields are displayed on your forms, they provide an easy way to customize the input forms for your lists and libraries. The trick is building SharePoint Designer workflows that automate the transitions between your content types. By flipping the value in your Content Type field via workflows, you make your list and library forms look dynamic–all without the effort of building custom ASPX pages.

Unfortunately, I hit a major snag this week while trying to modify the Content Type field in a reusable workflow in SharePoint Designer 2010. No matter how I set up my reusable workflow (e.g. assigning the workflow to work with one content type or ALL content types), I couldn’t use the Set field to… action in SharePoint Designer to reset the value in my Content Type field. Neither the Content Type nor the Content Type ID field appeared in the list of columns I could select to update. And I couldn’t add the Content Type or Content Type ID field as Associated Columns either.

reusable-workflow-01

I did some research, talked with a few smart folks and finally figured out why the Content Type field cannot be modified via a reusable workflow. Unlike “normal” list workflows, reusable workflows aren’t tied to a specific document library or list when they are created. Reusable workflows are built and published independently so they can be ported–or assigned–to any of your site collection’s libraries or lists. Unfortunately, the portability that makes the reusable workflows so useful also inhibits the workflow’s ability to modify the Content Type field.

When you associate a content type to a document library or list in SharePoint, the document library or list sees and recognizes the new content type’s ID. Because it knows the content type IDs that are associated to your list/library, SharePoint Designer allows you to query against the content type and update it via a workflow. Reusable workflows aren’t associated with document libraries or lists until after they’re published. As a result, SharePoint Designer can’t see or obtain any relevant content type ID(s) during workflow creation. This is why SharePoint Designer locks out the Content Type and Content Type ID fields from being updated via reusable workflows.

The only ways I’ve found to work around this issue are:

  1. Use list workflows instead of reusable workflows.
  2. Use reusable workflows, but leave out the Content Type field flipping. Your users will just have to reset the Content Type field by hand.

Anyone have additional ideas?

9 comments

  1. Just to make sure I understand, are you switching the content types only between new, edit and display forms to dynamically display or not display certain fields in each form type? Or are you switching the content types based on some other criteria?

    1. I’m tying content types to different steps in my work processes and then changing out the content type on the fly via workflow so I can change out which fields display on the new form and edit form.

      1. Ugh, I didn’t see your response before I wrote my other response. And my other response sounds a bit disjointed. What I meant to say was that you can also use

        SPField.ShowInNewForm = False
        http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.showinnewform(v=office.12).aspx

        and

        SPField.ShowInEditForm = True
        http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.showineditform(v=office.12).aspx

        I am not 100% certain, but you might be able to set those properties in SharePoint Designer

  2. Ok, so I read your other post. I think the answer to my previous question is that you want certain items to show in the new form and certain items to show in the display form. Another way you can do that is set the property on the SPField (List Column) ShowInNewForm (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.showinnewform(v=office.12).aspx) and ShowInEditForm (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.showineditform(v=office.12).aspx) to true. There are a variety of ways to set these properties (PowerShell, code, web services) but my guess (although I haven’t tried) is that you can set them in SharePoint Designer too.

  3. Good to know changing content types only work in List Workflows. Wish you could do a reusable and just have it automatically add any needed content types.

    ‘Course I also want someone to pay my Visa bill automatically, too.

  4. Or you can set up a utility workflow on a utility list. e.g. changing a contact type from internal to external
    1. Create a content type ‘Contact Request Content Type Change Action’ or whatever, this must have a specifying the content type to change to, and lookup to the original contact record
    2. Create a utility list ‘Contact Request Actions’ and #1 as a content type
    3. Create a utility workflow that runs #2 on creation of records i.e. include an if condition to process records of type #1
    4. Use a if condition in #3 to check the “content type to change to field” to change the Contact record to, add as many if conditions for the content type value.

    Hope this was clear enough.

  5. did you find a good answer to how to handle this fully? I have reusable workflow that creates a copy of a task for a new date when completed but I cannot set the content id so it is would not create as needed with the correct content type fields.

Leave a comment