Forum Discussion

rhankey's avatar
rhankey
Contributor
8 months ago

How to complete an optional import/validate/load workflow channel via the api

I have an IsOptional=True direct connect Import/Validate/Load Workflow channel.  I would like to be able to Complete this Workflow channel via the OS api without having to import/validate/load anything, the same as if someone selected the 'Complete Workflow' button just to the right of the 'Clear' button in OnePlace.  Actually, I have a number of such workflows, some are only required for M12 and others are placeholders for data that is being copied directly into the cube from other non-linked cubes.

I can complete/revert the Workflow channel if it is set to Workspace using BRApi.Workflow.Status.SetWorkflowStatus().  And I can revert Import/Validate/Load workflows with the SetWorkflowStatus() too, but I do not appear to be able to complete the WF unless I'm at the last step or advance the steps with SetWorkflowStatus().

The BRApi.Import.Process.* functions will advance me through the Import/Validate/Load steps, but I cannot see how to do so without the functions importing data.

I want to complete this optional workflow via the OS api without the workflow doing anything.

Any thoughts?

Thanks

  • rhankey  - I could not able to find the BRAPI for complete WF but you can use the below to complete the WF. It will complete all the step and you can see the green check. BTW if you were able to find the API do let me know. 

    Note: It is working even if the optional load is set to False. So make sure you test in the Test environment before running in Production. 

    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.DataLoadTransform, WorkflowStatusTypes.Completed, "Auto completing Import", "Error autocompleting ", "Auto completing", Nothing)
    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.ValidateTransform, WorkflowStatusTypes.Completed, "Auto completing Validate", "Error autocompleting ", "Auto completing", Nothing)
    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.ValidateIntersection, WorkflowStatusTypes.Completed, "Auto completing Int", "Error autocompleting ", "Auto completing", Nothing)
    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.LoadCube, WorkflowStatusTypes.Completed, "Auto completing Workspace", "Error autocompleting Load", "Auto completing", Nothing)

     

  • Krishna's avatar
    Krishna
    Valued Contributor

    rhankey  - I could not able to find the BRAPI for complete WF but you can use the below to complete the WF. It will complete all the step and you can see the green check. BTW if you were able to find the API do let me know. 

    Note: It is working even if the optional load is set to False. So make sure you test in the Test environment before running in Production. 

    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.DataLoadTransform, WorkflowStatusTypes.Completed, "Auto completing Import", "Error autocompleting ", "Auto completing", Nothing)
    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.ValidateTransform, WorkflowStatusTypes.Completed, "Auto completing Validate", "Error autocompleting ", "Auto completing", Nothing)
    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.ValidateIntersection, WorkflowStatusTypes.Completed, "Auto completing Int", "Error autocompleting ", "Auto completing", Nothing)
    BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.LoadCube, WorkflowStatusTypes.Completed, "Auto completing Workspace", "Error autocompleting Load", "Auto completing", Nothing)

     

    • rhankey's avatar
      rhankey
      Contributor

      Thanks Krishna.  Your suggestion works, and does exactly what I wanted.  I could have sworn I tried those steps several times yesterday to no avail.  For some reason I couldn't advance past the first step.

  • sameburn's avatar
    sameburn
    Contributor II

    For your particular use case sounds like you want to bypass real WF actions and just set WF step to complete.  If this is the case you can achieve this with a workspace as your final WF step and use something similar to the api's Krishna  has shared via a Dashboard Extender BR (using XFSelectionChangedTaskResult object) to complete e.g something like this?

    Dim wfClusterPK As New WorkflowUnitClusterPk
    Dim selectionChangedTaskResult As New XFSelectionChangedTaskResult()								
    ' Pass in variables
    Dim profileName As String = args.NameValuePairs.XFGetValue("WFProfile")
    Dim scenario As String = args.NameValuePairs.XFGetValue("Scenario")
    Dim time As String = args.NameValuePairs.XFGetValue("Time")
    
    ' Used to complete a workspace
    wfClusterPK = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, profileName, scenario, time)
    BRApi.Workflow.Status.SetWorkflowStatus(si, wfClusterPK, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, "Workspace Completed", "", "Admin clicked complete workflow", Guid.Empty)
    				
    ' Used to update the wfstatus automatically
    selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
    selectionChangedTaskResult.IsOK = True							
    selectionChangedTaskResult.ShowMessageBox = True
    Return selectionChangedTaskResult

     

     

     

    Hope this helps

    • rhankey's avatar
      rhankey
      Contributor

      Thanks for the response.

      Setting status StepClassificaiton.Workspace to Complete will only work if the Workflow channel is a Workspace, or the current step is a Workspace.  If not, you'll get a runtime error.  In my instance, I want to be completing Import/Validate/Load channels, for which Krishna's response does work.