05-02-2023 12:01 PM - last edited on 05-02-2023 04:01 PM by JackLacava
Im trying to create a workflow Event Handler that kicks off when lets say a period is locked April 2023 will then kick off a stored procedure that copies data from a table leveraging the wtk of the locked period.
05-03-2023 03:30 AM
... and?
This is fairly straightforward; if you could elaborate a bit on what difficulty you're encountering, I'm sure that someone would be able to help.
05-03-2023 04:29 AM
@AndoAssuming that you want to trigger a procedure as soon as you click on Lock Workflow
1. Create a Workflow Event Handler that will trigger copy leveraging the wtk of the locked period.
Namespace OneStream.BusinessRule.WorkflowEventHandler.WorkflowEventHandler
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As WorkflowEventHandlerArgs) As Object
Try
Dim returnValue As Object = args.DefaultReturnValue
args.UseReturnValueFromBusinessRule = False
args.Cancel = False
Select Case args.OperationName
Case Is = BREventOperationType.Workflow.WorkflowLock
If args.isBeforeEvent = True Then
Dim Mywf As WorkflowUnitClusterPk = DirectCast(args.Inputs(0), WorkflowUnitClusterPk)
Dim timeName As String = brapi.Finance.Time.GetNameFromId(si, Mywf.TimeKey)
CopyData(timeName)
End If
End Select
Return returnValue
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
Sub CopyData(timeName As String)
'Write your SQL query to copy data according to the time value
End Sub
End Class
End Namespace