Forum Discussion

mgreenberg's avatar
mgreenberg
Contributor II
3 years ago

Is there a way to automatically Validate, Process etc after Import Step (or Forms or Journals)?

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.

  • mgreenberg's avatar
    mgreenberg
    Contributor II

    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.

    • ckattookaran's avatar
      ckattookaran
      VIP

      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
      
  • NicolasArgente's avatar
    NicolasArgente
    Valued Contributor

    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.

  • 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.