Forum Discussion

pavel-wbr's avatar
pavel-wbr
New Contributor II
8 months ago

change Workflow Status from data management

Hi all, 

I use the dashboard to trigger data import from external database. After successfull import I want to make the workflow step (type Workspace) complete by calling SetWorkflowStatus.

Strange thing is that is does work when I directly call the Extensibility rule from Button, but it does not when I call the same rule from data management process. Do you know why this happens and how can this be bypassed? 

Thanks for help!

Pavel

 

  • FredLucas's avatar
    FredLucas
    Contributor III

    Hi pavel-wbr,

    If by "directly call the extensibility rule from button" you mean the execute extender rule button (next to the compile rules button) and not a dashboard button, then my guess would be that your code might not be under the right "case" statement.

    If you open a new Extensibility Rule you'll see that there're two areas, the "Case Is = ExtenderFunctionType.Unknown" that executes from that button and the "Case Is = ExtenderFunctionType.ExecuteDataMgmtBusinessRuleStep" that gets executed when launched from a data management step.

    If this is the case, you should be ok just by moving or copying and pasting the code to this last area of the rule.

    Hope this helps.

    • pavel-wbr's avatar
      pavel-wbr
      New Contributor II

      Hi Aymar, 

      here is the code I use:

      	Public Function CompleteWorkflow(ByVal si As SessionInfo, ByVal wfClusterPk As WorkflowUnitClusterPk) As XFSelectionChangedTaskResult
      		Try				
      			Dim selectionChangedTaskResult As New XFSelectionChangedTaskResult()
      		
      			'Get the workflow Info object, retrieve and the Workspace Workflow task and set its status ti COMPLETED	
      			Dim wfStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfClusterPk, True)
      			Dim wfTask As TaskInfo =  wfStatus.GetTask(New Guid(SharedConstants.WorkflowKeys.Tasks.Workspace))
      			If Not wfTask Is Nothing Then
      
      				
      				
      				
      				If (debug) Then ' DEBUG - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      					BRApi.ErrorLog.LogMessage(si, "#DEBUG: IDB_GeneralHelper / CompleteWorkflow: ", $"task: {wfTask.Description} || status: {wfTask.Status}"
      					)
      				End If ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      				
      				If wfTask.Status <> WorkflowStatusTypes.Completed Then
      					'Update the workspace workflow to COMPLETED
      					Dim wfRegClusterDesc As String = BRApi.Workflow.General.GetWorkflowUnitClusterPkDescription(si, wfClusterPk)
      					
      					BRApi.Workflow.Status.SetWorkflowStatus(si, wfClusterPk, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, StringHelper.FormatMessage(Me.m_MsgWorkflowCompleted, wfRegClusterDesc), "", Me.m_MsgWorkflowCompletedReasonButton, Guid.Empty)							
      
      					If (debug) Then ' DEBUG - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      						BRApi.ErrorLog.LogMessage(si, "#DEBUG: IDB_GeneralHelper / CompleteWorkflow: ", "step completed!"
      						)
      					End If ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      					
      				End If
      			End If
      
      			selectionChangedTaskResult.IsOK = True							
      			selectionChangedTaskResult.ShowMessageBox = False
      			selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
      
      			Return selectionChangedTaskResult							
      						
      		Catch ex As Exception
      			Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
      		End Try			
      	End Function	

      I am sure is processed it creates a debug record in Error log.

      I use no args here.

      It should work, I have no idea why it doesn't. 

      Thanks for help!

      Pavel

      • FredLucas's avatar
        FredLucas
        Contributor III

        Hi pavel-wbr,

        Have you tried refreshing the application or moving to a different workflow and get back to the one you expected to have been updated to understand if this could be due to the lack of the refresh?

        Only dashboard extender rules are able to return a XFSelectionChangedTaskResult object which is the one that contains the info required for OS to refresh the workspace. If you trigger a DataManagement Sequence that triggers a dashboard extender rule your Workspace won't get refreshed automatically and you'll have to manually do it to see the outcome.

        If you are looking for a way to trigger have the Workspace updated and also trigger other Data Management steps, you could have the dashboard extender launching the data management sequence for you. You might find this post interesting: https://community.onestreamsoftware.com/t5/Rules/Running-DM-package-from-the-BR-and-completing-the-workflow-step/m-p/34828#M3568

  • adoat's avatar
    adoat
    New Contributor III

    Hello Pavel,

    My guess is that you are using in your function some "args." that are coming only from the Dashboard args "library".

    If you manage to find which one is a Dashboard one, and replace by either a DataManagement args or the Pov of the data management job or any other variable, you should be able to pull it.

    Not having your code makes it difficult to identify exactly what would be the cause.

    Hope this helps, otherwise feel free to drop the code here and I can give it a quick look.

     

    Kind regards,

     

     

    Aymar

  • pavel-wbr's avatar
    pavel-wbr
    New Contributor II

    I think I found the solution, the dashboard needs to be refreshed at the end. Then I create the data management process it runs in backround and does not refresh the dashboard!

    This is the problem 😄 â€Œâ€Œ

    The problem is how to force refresh of the dashboard from data management task...

    • FredLucas's avatar
      FredLucas
      Contributor III

      Great news, that's aligned with my suspicion then.

      You might want to review my reply in order to solve that refresh issue 🙂