none
Workflow: add an item to the list with a SPECIFIC Content Type ? RRS feed

  • Question

  • Is it possible. Only  items with default content type got created for me.. Even if I set the Content Type value to the desired content type.

     

    thanks in advance,

    Marina

    Friday, May 18, 2007 3:13 PM

Answers

  • I am talking to myself. but for the sake of correct answer.

     

    The problem was with custom list forms. 

    The ShaerPoint is not always correctly generate them when you make changes to the content type.

    I had to recreate some fields in my content types and recreate the new and edit  forms - now it works.

    But it is a quite an amount  of work.

    Tuesday, May 22, 2007 7:05 AM

All replies

  • I did not use this code in a workflow, but that should not matter.  The variable "myList" is the SPList that uses the content type and the item is being added to.

     

    Code Snippet

    SPContentType myCT = myList.ContentTypes[<content type name>];
     SPListItem myItem = myList.Items.Add();

    myItem["ContentTypeId"] = myCT.Id;
     myItem.Update();

     

    Hope that helps you out.
    Friday, May 18, 2007 7:26 PM
  • Thanks!

     

    I actually ment doing it in SharePoint Designer  in workflow editor (it's easier to code to get what you want ... than tomake SharePoint designer to do it :-) )

    But you gave me the idea to try to set ContentTypeID  instead of content type  name.

     

    thanks a lot!

    Marina 

    Monday, May 21, 2007 8:15 AM
  • It's definetly a bug in workflow editor.

    I choose action Add Item to the list and set Content Type field to the one of the list content type. They care available from the drop-down box in the new item wizard. But the item that gets created still gets the default list content type.

     That why it uses the wring doc template to create it. ( btw, the list is actually doc library)

     

    Does anyone has a tip if its possible to report the bug somehow?

     

    thanks,

    Marina

    Monday, May 21, 2007 10:20 AM
  • I am talking to myself. but for the sake of correct answer.

     

    The problem was with custom list forms. 

    The ShaerPoint is not always correctly generate them when you make changes to the content type.

    I had to recreate some fields in my content types and recreate the new and edit  forms - now it works.

    But it is a quite an amount  of work.

    Tuesday, May 22, 2007 7:05 AM
  • I have a similar problem, one doc. library with 2 content types, each with a different Word template document.

    I create my document library for Word 2003 and 2 Content Types and make no changes after.

     

    When I use Create item (using Designer) and set the Content type=2nd one I have the Word document from the 1st Content type (which is the default).

    I'm using Word 2003 and MOSS 2007.

     

     

    Tuesday, May 22, 2007 8:27 PM
  • eh... for sake of a solution?  How about sharing it?
    Saturday, August 9, 2008 3:07 PM
  • ... and make it clear whether this was a SPD 2007 Worklflow question or not.

    If it wasn't an SPD workflow it should have been posted to the Workflow forum ....  (for future reference)


    [The SharePoint -Workflow forum is for all kinds of workflows including SPD workflows, but those (SPD workflows) and only those can instead be posted here.]
    Saturday, August 9, 2008 4:50 PM
  • It's not really a workflow question actually.  He was having the same issue as everyone else who tries to use multiple content types and the SharePoint designer custom forms.  When you create a list item, it always gets the default content type.  I tried using a Workflow, which seems like is what he tried to do, to set the content type id to a static value (since each content type has its own form).

    The problem is that A) the Content Type field is read only and B) the content type id field does not show up in the workflow editor.  It sounds to me like he might have figured out a way to trigger a workflow, pull from the custom field containing the content type (hardcoded) in the forms input area, and then update the list item with an action in the workflow.  All this just to add the item using the correct content type.  Someone shoot me square in the face please to end this madness ;)

    I am still trying to figure out how he did it with the column type since I can't find the content type id field in the workflow editor of sharepoint designer to set it in the workflow.  This has to be something I can have "non programmers" set in the forms when they design them...  SO...  MICROSOFT Developers, are you out there?  Hrrmm... big echo.

    I know, I don't have a billion dollars to give you guys so I'm not important but come on... this project is for global health.

    UPDATE:  I was able to get it working with a workflow and custom column like the dude above.  Here are my steps:
    http://forums.msdn.microsoft.com/en-US/sharepointcustomization/thread/20ca2f32-bcaa-4053-b216-56fd14946148

    Good luck and I hope you have more patience than I do.
    • Edited by Tom Goddard Saturday, August 9, 2008 11:48 PM Edee
    Saturday, August 9, 2008 9:34 PM