Skip to main content
Contributor
October 29, 2024
Solved

how to work the table WorkflowLock

  • October 29, 2024
  • 1 reply
  • 0 views

Hi Everyone.

I had a Business Rule that checked the Workflow table to see if a scenario was blocked, but it always showed WFProfiles as blocked. I don’t know where this information is coming from, as those WFProfiles were unblocked in the environment but appeared as blocked in the table. How can I verify this information?

Marco_0-1730230577703.png

 

Best answer by JoakimK

I am not sure as to why you are leveraging the table for such a check, as the lock on a WF is a combination of Workflow, Scenario and Time in combination.

Normally we use other functionality, here is an example of a simple check:

' Create stringbuilder			
Dim sb As New Text.StringBuilder
				
'Logic to check if a WF is locked and perform action or not
Dim wfClusterPK As New WorkflowUnitClusterPk(si.WorkflowClusterPk.ProfileKey,si.WorkflowClusterPk.ScenarioKey,si.WorkflowClusterPk.TimeKey)
'Get the Workflow Overall Status
Dim wfStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfClusterPk,True)

'Only log the error if wfStatus NOT locked
If Not wfStatus.Locked Then 
    	sb.AppendLine("Test 1: WF Status is NOT Locked")
'Only log the error if wfStatus IS locked
Else If wfStatus.Locked 
    	sb.AppendLine("Test 2: WF Status IS Locked")
End If
				
' Log Result -> Throw Error				
Throw New XFException(Convert.ToString(sb))

Regards, Joakim

1 reply

JoakimKOneStream EmployeeAnswer
OneStream Employee
November 29, 2024

I am not sure as to why you are leveraging the table for such a check, as the lock on a WF is a combination of Workflow, Scenario and Time in combination.

Normally we use other functionality, here is an example of a simple check:

' Create stringbuilder			
Dim sb As New Text.StringBuilder
				
'Logic to check if a WF is locked and perform action or not
Dim wfClusterPK As New WorkflowUnitClusterPk(si.WorkflowClusterPk.ProfileKey,si.WorkflowClusterPk.ScenarioKey,si.WorkflowClusterPk.TimeKey)
'Get the Workflow Overall Status
Dim wfStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfClusterPk,True)

'Only log the error if wfStatus NOT locked
If Not wfStatus.Locked Then 
    	sb.AppendLine("Test 1: WF Status is NOT Locked")
'Only log the error if wfStatus IS locked
Else If wfStatus.Locked 
    	sb.AppendLine("Test 2: WF Status IS Locked")
End If
				
' Log Result -> Throw Error				
Throw New XFException(Convert.ToString(sb))

Regards, Joakim