Thursday, October 11, 2012 5:16 PM
I struggled with associating my workflow with a document library and frankly, I forgot exactly how I did it.
I'm pretty sure I also associated the workflow with a custom content type (e.g. CT1). Anyway, the workflow works fine for CT1 documents uploaded to the library.
Now, I have added another custom content type (CT2) to the library and this works nicely (i.e. the document information panel exposed after the file is uploaded gives me a choice of content type and the form changes accordingly).
The problem: I want only CT1 documents associated with this workflow but strangely both content types (CT1 and CT2) are sent to the workflow.
I followed the simple directions at this link: Remove a workflow association (SharePoint Server 2010) on Technet but I see no evidence of the workflow being associated with this library. Instead, I get this indication of no workflows associated with this list as follows:
When I click the above dropdown list of content types, I see that CT1 is indeed (properly) associated with the list and then when I select CT2, I get confirmation that there is NO workflow associated with CT2. Yet, the workflow history log shows that uploading a doc of type CT2 is still being passed to the workflow. How can I shake off this association so that only CT1 documents are presented to the workflow?
Friday, October 12, 2012 9:52 AMModerator
I understand that you cannot remove a workflow associated with a document library. What do you mean by 'both content types are send to workflows'?
I assume that you are talking about a reusable workflow created in SharePoint designer. Since the workflow is not shown in the workflow settings page for the document library, can try to remove the workflow from the CT1.
- Open the document library in browser.
- Click Library Setting (Choose Advanced Settings to allow manage content types ). Click on CT1 to open the content type information.
- Click on workflow settings .Find the reusable workflow add remove it.
- Then open the workflow in SharePoint designer and associate it to CT1 again.
TechNet Community Support
Tuesday, October 16, 2012 5:18 PM
I believe I understand this problem now and I created a workaround which is an acceptable resolution.
SUMMARY of ORIGINAL PROBLEM (restated for clarity):
- one doc library supporting 2 content types (CT1 and CT2)
- doc library has no workflows associated with it as a list (library)
- CT1 has a unique custom reusable workflow associated with it; let's call it WorkflowCT1 (it creates no Task)
- CT2 has a unique custom reusable workflow associated with it; let's call it WorkflowCT2 (creates Approval Task)
- these workflows do NOT check the Content Type of the current item
- that is, each workflow assumes it will only be invoked for the Content Type with which it is associated
- BUT I discovered this is not the case. Upload process will ALWAYS invoke the workflow associated with the default content type for the library!
- So, if CT1 is configured as default for the library AND the default choice in the dropdown box for ContentType is NOT changed, WorkflowCT1 is invoked, runs OK and ends
- But, with CT1 as the default for the library and the user selects CT2 in the dropdown box, the document information panel (DIP) changes properly to the metadata for CT2 but WorkflowCT1 is invoked - not WorkflowCT2!
- Further testing confirms this by changing the default content type for the library to be CT2.
- With CT2 as default for the library, choosing CT1 properly displays DIP for CT1 but Workflow History Logs show that WorkflowCT2 is invoked (instead of WorkflowCT1).
New WORKAROUND step added to each workflow eliminates problem of workflows failing when entered for wrong content types:
- WorkflowCT1 checks [%Current Item: Content Type%] for CT1; if not equal to CT1 stop workflow.
- WorkflowCT2 checks [%Current Item: Content Type%] for CT2; if not equal to CT2 stop workflow.
- When CT1 is the default and user does NOT change to CT2, then only WorkflowCT1 is invoked.
- When CT1 is the default and user changes SELECTION to CT2, then both workflows are invoked; WorkflowCT1 is invoked and ends immediately; WorkflowCT2 is invoked, sets some properties on the item and creates an Approval task.
- When CT2 is the default and user does NOT change to CT1, then only WorkflowCT2 is invoked and works OK.
- When CT2 is the default and user changes CT dropdown SELECTION to CT1, then both workflows are invoked; WorkflowCT2 is invoked and exits properly with no work done except for logging to workflow history; WorkflowCT1 is invoked and sets current item values properly.
In my view, only the workflow associated with a content type should be invoked. This seems like a bug. What do you think?
Wednesday, October 17, 2012 10:31 AMModerator
I understand thar when you upload the document to the library, only the workflow associated to the default content type invokes. This is the normal behavior. After you upload the document to the library, the Editform.aspx page appears. You can change the content type here. But the document is already uploaded to the lirary using the default content type and invokes the workflow(You can open the document library in two tabs to see the changes). After you change the content type and click save, the content type for the uploaded document changes. This is the item modified event not the item created event. So it won't trigger the another workflow again.
TechNet Community Support
Wednesday, October 17, 2012 9:06 PM
OK, as I understand you, most of what I am seeing here in my testing is "normal behavior".
So, how do you recommend I accomplish the objectives?
- Need a library to support 2 content types being uploaded
- Need CT1 to be processed by WorkflowCT1 only (and nothing else)
- Need CT2 to be processed by WorkflowCT2 only (and nothing else)
Apparently, The first content type will be the default content type according to ChangeContentTypeOrder.aspx page so how is this overall objective best accomplished?
Thursday, January 31, 2013 12:22 AM
I am facing the same problem. Did you manage to solve it?