none
Workflow "Failed on Start" when started via Powershell. Condition not authorized.

    Question

  • Hi,

    I recently modified a pre-exisiting, pre-working workflow to add a "Is User in a Sharepoint Group" condition from SPDActivities CodePlex project.

    Anyway if I initiate the workflow manually it all works correctly (including the new condition).  However when in production the workflow gets started via Powershell (which also creates the list item), and instead I get a "Failed to Start" in the SP UI, and in the logs I get the following:

    05/09/2012 19:04:58.39  w3wp.exe (0x119C)                        0x0F9C SharePoint Foundation          Workflow Infrastructure        98d8 Unexpected Microsoft.SharePoint.SPException: <Error><CompilerError Line="0" Column="0" Text="Activity 'ID273' validation failed: Property &quot;Condition&quot; has invalid value. Condition expression is invalid. The type: &quot;DP.Sharepoint.Workflow.Common, DP.Sharepoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0298457208daed83&quot; is not authorized for use in Workflow Rules or Conditions" /></Error>     at Microsoft.SharePoint.Workflow.SPNoCodeXomlCompiler.LoadXomlAssembly(SPWorkflowAssociation association, SPWeb web)     at Microsoft.SharePoint.Workflow.SPWinOeHostServices.LoadDeclarativeAssembly(SPWorkflowAssociation association)     at Microsoft.SharePoint.Workflow.SPWinOeHostServices.CreateInstance(SPWorkflow workflow)     at Microsoft.SharePoint.Workflow.SPWinOeEngine.RunWo... 
    05/09/2012 19:04:58.39* w3wp.exe (0x119C)                        0x0F9C SharePoint Foundation          Workflow Infrastructure        98d8 Unexpected ...rkflow(SPWorkflowHostService host, SPWorkflow workflow, Collection`1 events, TimeSpan timeOut)     at Microsoft.SharePoint.Workflow.SPWorkflowManager.RunWorkflowElev(SPWorkflow workflow, Collection`1 events, SPWorkflowRunOptionsInternal runOptions) 

    I checked the web.config (all the posts regarding "not authorized" points to a missing authorizedType entry) and I have the following (in the correct locations):

          <SafeControl Assembly="DP.Sharepoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0298457208daed83" Namespace="DP.Sharepoint.Workflow.InfoPath" TypeName="*" Safe="True" SafeAgainstScript="False" />
          <SafeControl Assembly="DP.Sharepoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0298457208daed83" Namespace="DP.Sharepoint.Workflow.Install" TypeName="*" Safe="True" SafeAgainstScript="False" />
          <SafeControl Assembly="DP.Sharepoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0298457208daed83" Namespace="DP.Sharepoint.Workflow" TypeName="*" Safe="True" SafeAgainstScript="False" />

          <authorizedType Assembly="DP.Sharepoint.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0298457208daed83" Namespace="DP.Sharepoint.Workflow" TypeName="*" Authorized="True" />

    The Powershell code I use to start them is as follows:

      foreach ($wf in $list.WorkflowAssociations | ? { $_.AutoStartCreate -eq $true }) {
          $oWeb.Site.WorkflowManager.StartWorkFlow($item, $wf, $wf.AssociationData, [Microsoft.SharePoint.Workflow.SPWorkflowRunOptions]::SynchronousAllowPostpone) | Out-Null
      }
     

    Is there another web.config I should be looking at?  Any other pointers to what is wrong?  Is there another method of checking that a user is a member of a Sharepoint group within a workflow?

    Thanks in advance

    Peter

    Wednesday, May 09, 2012 9:20 AM

Answers