SharePoint : First SharePoint Designer Workflow does not start Automatically


After publishing changes to an Auto Start Workflow using SharePoint Designer, one may find that the Workflow is not processed after a new item is created. However, after the second item is created, the Workflow is process as expected.

 If SharePoint logging is configured for Verbose output under category “SharePoint Foundation > Workflow Infrastructure”, the following error will occur if one attempts to start an unprocessed workflow directly after changes are published. 

 06/22/2016 09:29:52.61        w3wp.exe (0x24B4)        0x4D2C        SharePoint Foundation        Legacy Workflow Infrastructure        72fv        Unexpected        AutoStart Workflow: System.ArgumentException: The requested workflow task content type was not found on the SPWeb.     at Microsoft.SharePoint.SPList.PrepForWorkflowTemplate(SPWorkflowTemplate wt)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.StartWorkflowElev(Object context, SPWorkflowAssociation association, DateTime elevationTimeUtc, SPWorkflowEvent startEvent, SPWorkflowRunOptions runOptions)     at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.<>c__DisplayClass1.<AutoStartWorkflow>b__0(SPSite superUserSite, SPWeb superUserWeb)        e899889d-1985-b0fb-33e0-0c8ac6842a37

The Cause :

This issue can occur if the “Workflow Task” Content Type and/or “SharePoint Server Workflow Task” Content Type at the site collection level has unexpectedly damaged/changed/removed.

To confirm, run the below PS on “working” and “non-working’ site collections and compare the output..

$destWeb = Get-SPWeb <site collection URL>
$destWeb.ContentTypes | select Name

Solution – 1 (Follow Solution – 2 if you see an error while activating either ctypes/fields feature)

  1. Run STSADM.EXE -o deactivatefeature -name ctypes -url <site collection URL>
  2. Run STSADM.EXE -o deactivatefeature -name fields -url <site collection URL>
  3. Run STSADM.EXE -o activatefeature -name ctypes -url <site collection URL>
  4. Run STSADM.EXE -o activatefeature -name ctypes -url <site collection URL>

 

Solution – 2 (One of our testing scenario)

  1. Run STSADM.EXE -o deactivatefeature -name ctypes -url <site collection URL>
  2. Run STSADM.EXE -o deactivatefeature -name fields -url <site collection URL>
  3. Run STSADM.EXE -o activatefeature -name ctypes -url <site collection URL>

We saw an error here (below). It indicated that one of the field was present at sub site level (created under the site collection) but there was no corresponding feature associated for it. Unless we fix it, we couldn’t proceed further to recreate missing content types on the site collection.

STSADM.EXE: The field with Id {03e45e84-1992-4d42-9116-26f756012634} defined in feature {ca7bd552-10b1-4563-85b9-5ed1d39c962a} was found in the current site collection or in a subsite.

At line:1 char:1

+ STSADM.EXE -o activatefeature -name ctypes -url <site collection URL>
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 i. CategoryInfo          : NotSpecified: (The field with …r in a subsite.:String) [],
ii. RemoteException
iii.  FullyQualifiedErrorId : NativeCommandError

 

  1. So to proceed further, create test/mirror “ctypes” and “fields” feature folder in the /Templates/Features/ folder and then modify the feature.xml file to change the id, Title, Description and scope(web).

 

  • Navigate to the C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\FEATURES
  • Locate “ctypes” and “fields” features folders. Create a copy of these two folders and name them “testctypes” and “testfields”.
  • Run ” [guid]::NewGuid().ToString() | clip ”  twice from PowerShell window to generate new GUIDs. (when you run it, it will copy a new id to clipboard, open notepad and paste it, do it twice)
  • Open the feature.xml file from the respective folders of “testctypes” and “testfields”.
  • Change the id (id we got above using PS), Title, Description, and set the Scope = ”Web”. (since for us the problematic field was on sub site, if the field is on site collection itself, scope should be “Site”). Save the XML files.

 

  1. Run the below commands to enable new “testfields” feature on all sub sites which had the field id error (step 3)

 

  • $sitecol = get-spsite <site collection URL>
  • $siteCol.AllWebs | where { $_.fields[[guid]’03e45e84-1992-4d42-9116-26f756012634′].staticname -ne $null } | % { $_.url; Enable-SPFeature -url $_.url -Identity testFields -Force }

 

  1. Run the below commands to enable new “testctypes” on all sub sites which had the field id error (step 3)
  • Enable-SPFeature -Url <Sub Site URL> -Identity testctypes -Force

 

  1. Once the test ctypes and fields are successfully enabled on the problematic subsites, run the below commands to disable them. (This will help us getting rid of problematic field)

 

  • $siteCol.AllWebs | where { $_.fields[[guid]’03e45e84-1992-4d42-9116-26f756012634′].staticname -ne $null } | % { $_.url; disable-SPFeature -url $_.url -Identity testFields -Force }
  • Disable-SPFeature -Url <Sub Site URL> -Identity testctypes -Force

 

  1. Run the below commands to uninstall the test ctype and fields.
  • Uninstall-SPFeature -Identity testfields
  • Uninstall-SPFeature -Identity testctypes

9. Run the below commands to enable the original ctypes and fields features on this site collection. Once done, get output of available content types on the site

collection again and ensure all content types are regenerated.

  • Enable-SPFeature -Url $siteCol.Url -Identity Fields
  • Enable-SPFeature -Url $siteCol.Url -Identity ctypes

 

How to identify problematic sub sites

================================

When we received this error while activating ‘ctypes”  .. STSADM.EXE: The field with Id {03e45e84-1992-4d42-9116-26f756012634} defined in feature

{ca7bd552-10b1-4563-85b9-5ed1d39c962a} was found in the current site collection or in a

subsite.

At line:1 char:1

+ STSADM.EXE -o activatefeature -name ctypes -url < Site Collection URL >

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo          : NotSpecified: (The field with …r in a subsite.:String) [],

RemoteException

+ FullyQualifiedErrorId : NativeCommandError

 

— We dumped all features from this site collection + all sub-sites under that. We didn’t find any feature matching the above feature id.

Then, we dumped all the fields from all sites +all subsites and we found the above field id in two sub-sites:

 

< Sub Site URL 1 >

< Sub Site URL 2 >

 

Post By : Sachin Shah [MSFT]


Comments (0)

Skip to main content