07-14-2022 04:24 PM
In our people planning when you hit Complete on the Workspace it automatically goes through the Import, validate, Load steps. Is there any way to do this when you start with Import, Forms or Journals and have it only stop if there is an error? It would be much nicer if the user could kick it off and go do something else and have it be done when they get back.
07-15-2022 02:37 AM
Hello,
Yes it is possible. You could have a look at this article that is close to what you need : https://onestreamsoftware.service-now.com/sp/?id=kb_article_view&sys_kb_id=3cfcb981db191b808a435eea4...
I would like you to see also this code : https://community.onestreamsoftware.com/t5/Accepted-Code-Samples/Extender-Automate-Import-Validate-L...
Please give a kudo if it helps,
Thanks
07-15-2022 07:53 AM
Hi Nicolas - thanks for the reply. I looked at the article and that is just about batch posting. What I am looking to do is when you Click Complete Workflow on the Input Forms or Input Journals or after you upload a file on the Import step that it automatically processes the remaining steps (Validate, Process, Confirm etc). It look like that snipet would do that I just dont know how to call that snipet since this is standard OS functionality. I dont want to have to add a Workspace step to do it.
07-15-2022 11:23 AM
For some reason I like using
BRApi.Import.Process.ValidateTransformation
BRApi.Import.Process.ValidateIntersections
BRApi.Import.Process.LoadCube
BRApi.DataQuality.Process.ExecuteProcessCube
vs. the Harvest approach. It is more readable than the other approach. Here is a snippet that I use. This is been done from a Dashboard button, so in your case those cannot be used (assuming you are taking the approach of using an Event handler)
Private Function LoadToCube(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal args As DashboardExtenderArgs) As XFSelectionChangedTaskResult
Try
Dim selectionResult As New XFSelectionChangedTaskResult()
Dim wfProfile As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, si.WorkflowClusterPk.ProfileKey)
Dim wfProfileParent As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, wfProfile.ParentProfileKey)
Dim timeName As String = TimeDimHelper.GetNameFromId(si.WorkflowClusterPk.TimeKey)
Dim wfClusterPk As WorkflowUnitClusterPk = BRAPi.Workflow.General.GetWorkflowUnitClusterPk(si, $"{wfProfileParent.Name}.Event Load", "Plan_Weekly", timeName & "W1")
'Complete the IMPORT-VALIDATE-LOAD-PROCESS Workflow Steps
'Get the Workflow info so that we can determine which steps can be executed
Dim wfInfo As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfClusterPk, True)
If Not wfInfo Is Nothing Then
' 'Check whether load transfrom is enabled
If Not wfInfo.GetStep(StepClassificationTypes.DataLoadTransform) Is Nothing Then
Dim impProcessInfo As LoadTransformProcessInfo = BRApi.Import.Process.ExecuteParseAndTransform(si, wfClusterPk, Nothing, Nothing, TransformLoadMethodTypes.ReplaceBackgroundAllTimeAllSourceId, SourceDataOriginTypes.FromDirectConnection, True)
If impProcessInfo.Status = WorkflowStatusTypes.Completed Then
'Check whether validate transform is enabled
' perform validate transformation
If Not wfInfo.GetStep(StepClassificationTypes.ValidateTransform) Is Nothing Then
Dim valTranProcessInfo As ValidationTransformationProcessInfo = BRApi.Import.Process.ValidateTransformation(si, wfClusterPk, True)
If valTranProcessInfo.Status = WorkflowStatusTypes.Completed Then
' perfomr validate intersection
If Not wfInfo.GetStep(StepClassificationTypes.ValidateIntersection) Is Nothing Then
Dim valIntersectProcessInfo As ValidateIntersectionProcessInfo = BRApi.Import.Process.ValidateIntersections(si, wfClusterPk, True)
If valIntersectProcessInfo.Status = WorkflowStatusTypes.Completed Then
'Check whether we can load cube
If Not wfInfo.GetStep(StepClassificationTypes.LoadCube) Is Nothing Then
Dim lcProcessInfo As LoadCubeProcessInfo = BRApi.Import.Process.LoadCube(si, wfClusterPk)
If lcProcessInfo.Status = WorkflowStatusTypes.Completed Then
'Check whether we can process cube
If Not wfInfo.GetStep(StepClassificationTypes.ProcessCube) Is Nothing Then
Dim pcProcessInfo As ProcessCubeProcessInfo = BRApi.DataQuality.Process.ExecuteProcessCube(si, wfClusterPk, StepClassificationTypes.ProcessCube, False)
If Not pcProcessInfo.Status <> WorkflowStatusTypes.Completed Then
selectionResult.Message = "Process cube failed."
selectionResult.IsOK = False
selectionResult.ShowMessageBox = True
Return selectionResult
Throw ErrorHandler.LogWrite(si, New XFUserMsgException(si, Nothing, Nothing, "Process cube failed."))
End If
End If
Else
selectionResult.Message = "Load cube failed."
selectionResult.IsOK = False
selectionResult.ShowMessageBox = True
Return selectionResult
Throw ErrorHandler.LogWrite(si, New XFUserMsgException(si, Nothing, Nothing, "Load cube failed."))
End If
End If
Else
selectionResult.Message = "Validate intersection failed."
selectionResult.IsOK = False
selectionResult.ShowMessageBox = True
Return selectionResult
Throw ErrorHandler.LogWrite(si, New XFUserMsgException(si, Nothing, Nothing, "Validate intersection failed."))
End If
End If
Else
selectionResult.Message = "Validate Transformation failed."
selectionResult.IsOK = False
selectionResult.ShowMessageBox = True
Return selectionResult
Throw ErrorHandler.LogWrite(si, New XFUserMsgException(si, Nothing, Nothing, "Validate Transformation failed."))
End If
End If
Else
selectionResult.Message = "Load and Transform failed."
selectionResult.IsOK = False
selectionResult.ShowMessageBox = True
Return selectionResult
Throw ErrorHandler.LogWrite(si, New XFUserMsgException(si, Nothing, Nothing, "Load and Transform failed."))
End If
End If
End If
selectionResult.Message = "Cube loaded."
selectionResult.IsOK = True
selectionResult.ShowMessageBox = True
Return selectionResult
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
07-15-2022 08:57 AM
Without going into too much detail, i suggest that you have a look at the Event Handlers. It will require some coding. You should find some sample in the design doc too.
07-15-2022 09:33 AM
Import would use the Transformation Event Handler
Forms would use the Forms Event Handler
More details on Event Handlers can be found in the Design and Reference Guide or Api Guide.