How to Update UI Workflow Status When Run Via Extensibility Rule

RobbSalzmann
Valued Contributor

We have several workflows that involve many steps.  The requirement is to have a button in a dashboard that runs the entire sequence or sequences.  This is coded and works.

The problem is when running workflows using a BR, the UI status doesn't update unless the refresh button is clicked.  This action is not practical when operating in a dashboard because it closes the dashboard.

How can I update the UI workflow status indications from the business rule?

I need to go from this:

RobbSalzmann_0-1686078983970.png

To this:

RobbSalzmann_1-1686079008381.png

Without clicking this:

RobbSalzmann_1-1686157396227.png

 

Or leaving the dashboard.

8 REPLIES 8

NicolasArgente
Valued Contributor

Hi @RobbSalzmann 
Have you tried that :

 

'Can be called from a dashboard extender business rule:
Dim selectionResult As New XFSelectionChangedTaskResult()
selectionResult.WorkflowWasChangedbyBusinessRule = True
Return selectionResult

Source : Accepted Code Samples
Thanks

Connect with me on:
LinkedIn: https://www.linkedin.com/in/nicolas-argente/
Website: https://aiqos.io
If you want to lift yourself up, lift up someone else.

Thanks @NicolasArgente .  Yes, I have the following, with no effect on updating the UI:

 

  Dim selectionChangedTaskResult As XFSelectionChangedTaskResult = Nothing      
...

   selectionChangedTaskResult = New XFSelectionChangedTaskResult With { 
   	.IsOK = True, 
	.WorkflowWasChangedByBusinessRule = True, 
	.PovWasChangedByBusinessRule = True,
	.ChangeSelectionChangedUIActionInDashboard = True
	.ChangeSelectionChangedUIActionInDashboard = XFSelectionChangedUIActionType.Refresh
   }

...

Return selectionChangedTaskResult 

 

 

MikeG
Contributor III

I was able to get this to work.  There are API calls to complete each step along the way, Import > Validate > Load (or Process) or also Confirm steps.  See if you can grab snippets of the code below to support your specific rule and solution:

 

selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
selectionChangedTaskResult.IsOK = True
selectionChangedTaskResult.ShowMessageBox = True
'---other code
'----set status
If Not wfStatus.GetOverallStatus().Equals(WorkflowStatusTypes.Completed) Then

'Complete workspace
BRApi.Workflow.Status.SetWorkflowStatus(si, currentWF, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, "Workspace Completed", "", "User clicked complete workflow", Guid.Empty)
'Complete import
Dim objLoadTransformProcessInfo As LoadTransformProcessInfo = BRApi.Import.Process.ExecuteParseAndTransform(si, currentWF, "", Nothing, TransformLoadMethodTypes.Replace, SourceDataOriginTypes.FromDirectConnection, False)
'Complete validate
Dim objValidationTransformationProcessInfo As ValidationTransformationProcessInfo = BRApi.Import.Process.ValidateTransformation(si, currentWF, True)
Dim objValidateIntersectionProcessInfo As ValidateIntersectionProcessInfo = BRApi.Import.Process.ValidateIntersections(si, currentWF, True)
'Complete Load
Dim objLoadCubeProcessInfo As LoadCubeProcessInfo = BRApi.Import.Process.LoadCube(si, currentWF)

End If 'Not Completed
Return selectionChangedTaskResult

RobbSalzmann
Valued Contributor

Thanks @MikeG .  Can you show the instantiation and initialization of wfStatus and currentWF please?

I'm a bit confused by the BRApi call to set the status of the workflow to completed before running the steps below it?

Is the line 
"BRApi.Workflow.Status.SetWorkflowStatus(si, currentWF, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, "Workspace Completed", "", "User clicked complete workflow", Guid.Empty)"
the part that compels your workspace UI to update with the completed workflow?

I created a Workspace that essentially is a summary of all the Workflow tasks I want to automate.  In your instance, you would not need to complete the 'Workspace' complete step, you could delete that or comment it out, and in your solution the first step in your Workflow to complete would be the 'Import' task/step.

RobbSalzmann
Valued Contributor

@MikeG what I'm looking for is how to compel the UI to show that the steps are complete, without having to click the refresh button.  Can you isolate your suggestion to just the line that does this please?

@NicolasArgente was close.  I'm not certain on the exact line of code.  There is not a specific API to refresh the application, that is controlled and/or locked down by the platform.  But, my Workspace is indeed updating the Workflow statuses and showing the green check marks in my WFPOV.

selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
selectionChangedTaskResult.IsOK = True
selectionChangedTaskResult.ShowMessageBox = True
 
So the only line that is new is the ShowMessageBox = True.  I don't have the ChangedUIAction=Refresh API code that you are attempting to do.  From what I'm seeing in your code above.  You are not showing the 'how' you are setting the step completion.  If some of those Import steps taking minutes, then they will be running in the background and won't immediately show the green check-mark.  In my case, I get a series of notifications that the Background Task is Completed, then the green checkmarks start to appear.  So, it's sort of a timing thing and not instantaneous.
 
Lastly, and man this is a lot of free code to offer up Robb.  Ha!  I'm checking that the Workflow is Active and these are the local vars for currentWF and wfStatus:
 
If Not inputImportChannel.GetAttributeValue(scenTypeID,sharedConstants.WorkflowProfileAttributeIndexes.Active) = "0" Then
'Get current import WF status
Dim currentWF As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, inputImportChannel.Name, scenarioName, timeName)
Dim wfStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, currentWF, False)
 
Best regards,
Mike G
Archetype Consulting

RobbSalzmann
Valued Contributor

@MikeG thanks for the help!