Skip to main content
May 2, 2024
Solved

Lock all workflows and descendants using a business rule

  • May 2, 2024
  • 2 replies
  • 0 views

I'm creating a business rule to automatically lock all workflows and descendants using:  

BRApi.Workflow.Locking.LockWorkflowUnitDescendants(si, wfClusterPk, profileTypeFilter, workflowChannelKey)

but I'm getting the error: 'the item was not found'. I found an example online but it's not working for me. I didn't know what to populate wfClusterPk with so I defined it as (). I'm fairly new to VB.net and appreciate any help with this - thanks! 

 
  Dim wfClusterPk As New WorkflowUnitClusterPk()
  Dim wfChannelKey As Guid = Guid.Empty
 
  BRapi.Workflow.Locking.LockWorkflowUnitDescendants(si, wfClusterPk,     WorkflowProfileTypes.AllProfiles, wfChannelKey)
 
 
Best answer by Krishna

cap08  - Here is an example basically it is getting the current WF Profile and locking it using extender rule.

					Dim wfInfo As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si,si.WorkflowClusterPk)
	
	Dim A As String = wfInfo.Name
	brapi.ErrorLog.LogMessage(si,A)
	If wfInfo.Locked  Then
		Brapi.ErrorLog.LogMessage(si,"Not Locked")
		
	Else
		'BRApi.Workflow.Locking.LockWorkflowUnit(si,si.WorkflowClusterPk)
		
		
		BRApi.Workflow.Locking.LockWorkflowUnitDescendants(si,si.WorkflowClusterPk,workflowprofiletypes.InputImportChild,si.WorkflowClusterPk.ProfileKey)

		Brapi.ErrorLog.LogMessage(si," Locked")
		
	
End If

 

2 replies

KrishnaAnswer
May 2, 2024

cap08  - Here is an example basically it is getting the current WF Profile and locking it using extender rule.

					Dim wfInfo As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si,si.WorkflowClusterPk)
	
	Dim A As String = wfInfo.Name
	brapi.ErrorLog.LogMessage(si,A)
	If wfInfo.Locked  Then
		Brapi.ErrorLog.LogMessage(si,"Not Locked")
		
	Else
		'BRApi.Workflow.Locking.LockWorkflowUnit(si,si.WorkflowClusterPk)
		
		
		BRApi.Workflow.Locking.LockWorkflowUnitDescendants(si,si.WorkflowClusterPk,workflowprofiletypes.InputImportChild,si.WorkflowClusterPk.ProfileKey)

		Brapi.ErrorLog.LogMessage(si," Locked")
		
	
End If

 

cap08Author
May 3, 2024

I'll give this a try, thank you!

 

 

May 7, 2025

Can something similar be used to Unlock and Lock forms for a list of Workflows (i.e. 10 at a time)?  

Thanks for any insight.

cap08Author
May 12, 2025

I used this statement to close only the Import child, but you can probably change it to InputFormsChild - maybe this will get  you started

BRapi.Workflow.Locking.LockWorkflowUnitDescendants(si, childClusterPk, WorkflowProfileTypes.InputImportChild, wfChannelId)