Sharepoint change Content Type in Sharepoint Desig

2019-07-18 04:41发布

问题:

i trying to change document content type. I must use workflow, and the best way will by workflow create in sharepoint desingner. I know how do it programatical in visual studio

回答1:

I know this is an old question, but I figured this out:

You CAN do this using a SPD workflow (SPD 2007 or 2010). You can call the content type field in two ways:

  1. In a workflow, use the "If [field] equals [value]" or the "Set [field] to [value]"

  2. For the "If" statement, the field will be called "Content Type". The "Set" statement field will be called "Content Type ID". In either case you can assign the value based on available content types.

You do need to enable content types on the list or library settings. Here's an example workflow based on a custom list to record Accounts Payable entries:

List Column: Request Type (choice column with the choices of Reimbursement, Department Expense, Other)

List Content Types: Default, Accounts Payable, Accounts Receivable

If [Request Type] equals [Reimbursement]
then Set [Content Type ID] to [Accounts Payable]

When the workflow fires, it will only set the Content Type to Accounts Payable if the Request Type column is equal to Reimbursement.



回答2:

I just changed the content type of a list item through a workflow in SharePoint Designer 2010. When I added Set item from current list and chose Content Type ID the dropdown allowed me to select from the different content types. I didn't loose any data probably because my content types use some of the same fields.



回答3:

I'm pretty sure you can't, certainly not from a SP Designer workflow.

You have to remember that there is no way SharePoint can be sure that the two contenttypes (before and after) have the same sorts of columns, and even if they did, couldn't easily map values from the old contenttype to the new.

Since you noted you can program in Visual Studio, I checked your options with regard to the SharePoint object model. There's no method available on either an SPListItem or an SPFile with which to change the associated contenttype. So, as far as I know, you'd be reduced to reading the values from the old listitem and creating a new one (with the new contenttype association), using custom code.

I'm not sure if that's something I'd wanna do, besides the fact that you'd lose the Created and Modified information from the old listitem.

But yeah, that's your only option, I think...



回答4:

Of course you can use SPD workflow to change content type of an item. Naturally, the library where the item resides must be configure to accept both types. Here's a link to an application that makes use of this: http://www.sharepoint911.com/blogs/laura/Lists/Posts/Post.aspx?List=daba3a3b-c338-41d8-bf52-cd897d000cf3&ID=43&Web=dbb90e85-b54c-49f4-8e97-6d8258116ca0