Forum Discussion

Stulai's avatar
Stulai
New Contributor II
2 years ago

Simultaneously completed all WF forms for descendants.

Hello Everybody,


Could you please help to get a solution how to complete all WF forms at once for all descendants. We already got the extensibility rule for this purpose but it's completing all WF steps except forms. The function for form exists (brapi.Forms.Process.ExecuteCompleteForm(si, formPk)), but we are having trouble retrieving the formPk...
Would be highly grateful if someone can share an idea how to solve this.

Best Regards,

Svetlana 

 

  • Yeah sorry, the actual lists of forms are one level deeper, just change the For line adding .RequiredForms:

    For each formObj as XFFormSummaryInfo in objXFFormsForWorkflow.RequiredForms

    Intellisense is your friend...

  • JackLacava's avatar
    JackLacava
    Honored Contributor
    ' get all forms in the currently-selected Worflow cluster (wf/scenario/time combination)
    Dim objXFFormsForWorkflow As XFFormsForWorkflow = BRApi.Forms.Metadata.GetForms(si, si.WorkflowClusterPk)
    
    ' for each form
    For each formObj as XFFormSummaryInfo in objXFFormsForWorkflow
       ' retrieve the XFFormPk
       Dim objXFFormPk As XFFormPk = objXFFormSummaryInfo.FormPk
       ' ... your hacks here
    Next
    

     

    • Stulai's avatar
      Stulai
      New Contributor II

      Dear Jack,

      I truly appreciate your response and it looks like we are very close to finding the correct way to fill out all the forms, but we keep getting the following error, do you have any idea what is wrong with the below code?

      Our Extensibility Rule looks like this:

      #Region "Complete Workflow"

      For Each WFStep As String In WFEntities

      For Each WFProc As String In WFProcess

      Dim WorkFlowStep As String = WFStep & "." & WFProc
      Dim WFInfo As WorkFlowProfileInfo = BRApi.Workflow.Metadata.GetProfile(si, WorkFlowStep) 'create loop
      Dim WFCluster As New WorkflowUnitClusterPk(WFInfo.ProfileKey,si.WorkflowClusterPk.ScenarioKey, si.WorkflowClusterPk.TimeKey)
      Dim WfStatus As WorkflowInfo = BRApi.Workflow.Status.getworkflowstatus(si, wfcluster, False)


      Select Case WfStatus.name

      Case Is = "Form Input, Process, Confirm"
      ' get all forms in the currently-selected Worflow cluster (wf/scenario/time combination)

      Dim objXFFormsForWorkflow As XFFormsForWorkflow = BRApi.Forms.Metadata.GetForms(si, WFCluster)

      ' for each form
      For Each formObj As XFFormSummaryInfo In objXFFormsForWorkflow
      ' retrieve the XFFormPk
      Dim objXFFormPk As XFFormPk = formObj.FormPk
      brapi.Forms.Process.ExecuteCompleteForm(si, objXFFormPk)
      Next
      brapi.Forms.Process.ExecuteUpdateFormWorkflow(si, WFCluster, True)
      brapi.DataQuality.Process.ExecuteProcessCube(si, WFCluster, StepClassificationTypes.ProcessCube, False)
      brapi.DataQuality.Process.ExecuteConfirmation(si, WFCluster)


      'Case Is = "Import, Validate, Load"

      Case Is = "Workspace"
      BRApi.Workflow.Status.SetWorkflowStatus(si, si.WorkflowClusterPk, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, StringHelper.FormatMessage("", ""), "", "", Guid.Empty)
      ' Case Is = "ZZZ"

      End Select

      Next
      Next
       
      Dim selectionResult As New XFSelectionChangedTaskResult()
      selectionResult.WorkflowWasChangedbyBusinessRule = True
      Return selectionResult
       
      Catch ex As Exception
      Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
      End Try
      #End Region
      • JackLacava's avatar
        JackLacava
        Honored Contributor

        Yeah sorry, the actual lists of forms are one level deeper, just change the For line adding .RequiredForms:

        For each formObj as XFFormSummaryInfo in objXFFormsForWorkflow.RequiredForms

        Intellisense is your friend...

  • JackLacava / Stulai ,

    Can you help me with the declare of the WFProcess and WFStep?
    We try to implement this rule our self but we cannot get the script into the "for each" loop.

    Thanks in advance.

    "For Each WFStep As String In WFEntities

    For Each WFProc As String In WFProcess"

    • JackLacava's avatar
      JackLacava
      Honored Contributor

      You know Workflow names, they look like "MyProfile.Import", right? That's what they are building in the line that goes Dim WorkFlowStep As String = WFStep & "." & WFProc - WFStep would be "MyProfile" and WFProc would be "Import". 

      Now, in this case, they are populating WFStep with each string contained in a list called WFEntities, and WFProc with each string contained in a list called WFProcess. So before all this code, they probably have something like:

      Dim WFEntities as New List(Of String)
      WFEntities.Add("MyProfile")
      WFEntities.Add("SomeOtherProfile") ' etc etc
      
      Dim WFProcess as New List(Of String)
      WFEntities.Add("Import")
      WFEntities.Add("Forms") ' etc etc

      Does that make sense ?

      Looking at the name of their variables, they've probably used Entity names when naming their Profiles.