Skip to main content
Veteran
April 26, 2022

How to automate lock and unlock workflow using Business rule

  • April 26, 2022
  • 2 replies
  • 0 views

I am looking for a business rule or function to lock and unlock workflow and then set it as scheduled task.

2 replies

Contributor
April 26, 2022

Try 

brapi.Workflow.Locking.LockWorkflowUnitDescendants etc.

LeeBown_0-1650985004475.png

If you use these in an Extender Rule you can then run via a Data Management Sequence.

Lee

 

 

 

Contributor
June 15, 2022

Great find! However, the function asks for workflowChannelKey ... How can I generate that parameter for the suggested function:

BRApi.Workflow.Locking.LockWorkflowUnitDescendants(si, si.WorkflowClusterPk, WorkflowProfileTypes.AllProfiles, workflowChannelKey)

OS_PizzaAuthor
Veteran
June 17, 2022

I have created the below BR and it works like a charm . Let me know if it doesn't work for you.

 

Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As ExtenderArgs) As Object
Try


Dim wfClusterPk As New WorkflowUnitClusterPk()

Dim Pname As String = "Your workflow name"
Dim Sname As String = "Scenerio name"
Dim Tname As String = "Timeperiod Eg- 2022M4"

wfClusterPk = BRAPi.Workflow.General.GetWorkflowUnitClusterPk(si,Pname,Sname,Tname)


'To Lock
Brapi.Workflow.Locking.LockWorkflowUnit(si,wfClusterPk)


'To unlock
'Brapi.Workflow.Locking.UnlockWorkflowUnit(si,wfClusterPk)


Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function