Site Collection Reusable Workflows Triggered Multiple Times with Content Types


Badge +2

Nintex Workflow Structure in our application:-
1.There are 180 site collections and around 80K sub-sites across the site collection.
2.180 SharePoint content database are mapped with 8 Nintex content databases.
3.All the Nintex workflows are Site Collection Reusable workflow and published in site collection level.
4.Currently version, Nintex Workflow 2013 (3.1.10.0)  International,
5.Application has structured content type in each site collection level and attached the Nintex workflow in parent content type.
6.Child content types are attached with SharePoint library. We have 5 SharePoint library with attached 100+ content type in each sub-site level and each document upload workflow triggered.
7.Workflow started on new document upload request (Start Options:-Creating a new item will start this workflow.)
8.Average daily documents upload count is around ? 5 to 6K.

Steps to create a new site collection in our application:-
•Create bank Content Database
•Back Up existing site collection using below script:-
•Backup-SPSite -Identity $SiteCollectionToExportURL -Path $ExportPath -Confirm:$false
•Mapped newly created SharePoint Content Db to Nintex Content Db.
•Restore to new site collection using below script:-
•Restore-SPSite -Identity $ImportWeb -Path $ImportPath -ContentDatabase $ContentDB  -Confirm:$false
•De-activate and activate the Nintex workflow feature in new site collection.

Using below PowerShell script to published the Nintex workflows:-

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$filesLocation="E:PublishWFNWFsAccountSiteColl""

#loading the csv files
$URLs = Import-Csv -path ($filesLocation + "URLs.csv")
$WFNames = Import-Csv -path  ($filesLocation + "WFNames.csv")

ForEach($u in $URLs)
{
    #Target SharePoint site URL
    $WebURL=$u.URL
    $web = Get-SPWeb $WebURL
    #Nintex Web Service URL
    $WebSrvUrl=$web.Url+"/_vti_bin/nintexworkflow/workflow.asmx"
    $proxy=New-WebServiceProxy -Uri "$($webSrvUrl)?wsdl" -UseDefaultCredential
    $proxy.URL=$WebSrvUrl
    ForEach($wf in $WFNames)
    {
   
        #physical location of the nintex workflow template
        $WorkflowFile=$filesLocation+$wf.Location
        #Workflow name
        $wfName=$wf.Name
        #Get the Workflow from file
        $NWFcontent = get-content $WorkflowFile
        #upload and publish the workflow
        write-host "$($wfName) is being Published to site collection $($WebURL)" -ForegroundColor Yellow
        if($proxy.PublishFromNWFXml($NWFcontent, "" ,$wfName, $true))
        {
            write-host "$($wfName) published to site successfully." -ForegroundColor Green
        }
        else
        {
            write-host "There is some error in publishing $($wfName) to site." -BackgroundColor Red
        }
    }
     $web.Dispose()
}

Frequently getting below error message in ULS log:-

AutoStart Workflow: Microsoft.SharePoint.SPException ---> System.Runtime.InteropServices.COMException: <nativehr>0x80131904</nativehr><nativestack></nativestack>   

 at Microsoft.SharePoint.Library.SPRequestInternalClass.AddWorkflowToListItem(String bstrUrl, String bstrListName, Int32 lItemID, Int32 lItemLevel, Int32 lItemVersion, Guid workflowPackageId, Guid& pWorkflowInstanceId, Guid workflowTaskListId, String bstrStatusFieldInternalName, Int32 lAuthorId, String bstrModificationXml, Guid correlationId)   

 at Microsoft.SharePoint.Library.SPRequest.AddWorkflowToListItem(String bstrUrl, String bstrListName, Int32 lItemID, Int32 lItemLevel, Int32 lItemVersion, Guid workflowPackageId, Guid& pWorkflowInstanceId, Guid workflowTaskListId, String bstrStatusFieldInternalName, Int32 lAuthorId, String bstrModificationXml, Guid correlationId)     -

-- End of inner exception stack trace ---   

 at Microsoft.SharePoint.Workflow.SPWinOeEngine.CreateWorkflow(Object context, SPWorkflowAssociation association, SPWorkflowEvent startEvent, Boolean bCreateOnly)   

 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)

 

********************************************

System.Runtime.InteropServices.COMException: <nativehr>0x8102009b</nativehr><nativestack></nativestack>, StackTrace:  

 at Microsoft.SharePoint.Workflow.SPWinOeEngine.CreateWorkflow(Object context, SPWorkflowAssociation association, SPWorkflowEvent startEvent, Boolean bCreateOnly)   

 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)   

 at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass10.<RunWithSystemSiteAndWeb>b__f()   

 at Microsoft.SharePoint.SPSecurity.<>c__DisplayClass5.<RunWithElevatedPrivileges>b__3()   

 at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)   

 at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param)   

 at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode)   

 at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange, AssocType atyp)   

 at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.AutoStartWorkflow(SPItemEventProperties properties, Boolean bCreate, Boolean bChange)   

 at Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver.ItemUpdated(SPItemEventProperties properties)   

 at Microsoft.SharePoint.SPEventManager.RunItemEventReceiver(SPItemEventReceiver receiver, SPUserCodeInfo userCodeInfo, SPItemEventProperties properties, SPEventContext context, String receiverData)   

 at Microsoft.SharePoint.SPEventManager.RunItemEventReceiverHelper(Object receiver, SPUserCodeInfo userCodeInfo, Object properties, SPEventContext context, String receiverData)   

 at Microsoft.SharePoint.SPEventManager.<>c__DisplayClassa`1.<InvokeEventReceiver>b__7()   

 at Microsoft.SharePoint.SPSecurity.RunAsUser(SPUserToken userToken, Boolean bResetContext, WaitCallback code, Object param)   

 at Microsoft.SharePoint.SPEventManager.InvokeEventReceiver[ReceiverType](SPUserToken userToken, Guid tranLockerId, RunEventReceiver runEventReceiver, Object receivers, Int32 n, Object properties, SPEventReceiverOperationsType operationsType, Boolean& canceled, String& error)   

 at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPRemoteEventReceiverCallType remoteCallType, SPUserToken userToken, Guid tranLockerId, RunEventReceiver runEventReceiver, RunRemoteEventReceiver runRemoteEventReceiver, Object receivers, Object properties, Boolean checkCancel, SPEventReceiverOperationsType operationsType)   

 at Microsoft.SharePoint.SPEventManager.InvokeEventReceivers[ReceiverType](SPRemoteEventReceiverCallType remoteCallType, Byte[] userTokenBytes, Guid tranLockerId, RunEventReceiver runEventReceiver, RunRemoteEventReceiver runRemoteEventReceiver, Object receivers, Object properties, Boolean checkCancel, SPEventReceiverOperationsType operationsType)   

 at Microsoft.SharePoint.SPEventManager.HandleEventCallback[ReceiverType,PropertiesType](Object callbackData)   

 at Microsoft.SharePoint.Utilities.SPThreadPool.WaitCallbackWrapper(Object state)   

 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   

 at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   

 at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()   

 at System.Threading.ThreadPoolWorkQueue.Dispatch()


2 replies

Badge +5

Does this PowerShell script you use add your reusable workflow template to the parent document content type in each site collection? And is your workflow a reusable site collection workflow or just a reusable workflow template?

Just trying to understand...

Badge +2

Hi Victor - Yes, we are using Powershell script to publish the workflow and also attached the workflow with content type.

It is reusable site collection workflow and attached with parent document content type.

Reply