The OneStream Community is temporarily frozen until June 29th due to the ongoing maintenance. Please read the blog post here to learn more.
Forum Discussion
YanSavinsky
2 years agoNew Contributor III
Running DM package from the BR and completing the workflow step
I would like to give my users the ability to launch the DM sequence from the workflow step. I have the dashboard with the button that passes the parameters to the DM package and launches the package....
- 2 years ago
Create 1 Dashboard Extender rule with 2 functions - one to Complete and one to Revert. Do not do this by way of a DM Sequence. There is no API for Refresh Application. Take 1 step back to take 2 steps forward.
Hope this helps!
- 2 years ago
Hi YanSavinsky,
I believe the following solution will give you what you are looking for with minimal changes to your existing logic:
- Remove the last step from your DM Sequence - EPU_Complete_WF
- Create a Dashboard Extender Rule that triggers the DM Sequence and updates the WF Status in case of success (see snippet below)
- Update the button to trigger this dashboard Extender Rule instead
Case Is = DashboardExtenderFunctionType.ComponentSelectionChanged If args.FunctionName.XFEqualsIgnoreCase("ProcessDMSequenceAndUpdateWFStatus") Then '{REP_SolutionHelper}{ProcessDMSequenceAndUpdateWFStatus}{} Dim selectionChangedTaskResult As New XFSelectionChangedTaskResult() selectionChangedTaskResult.IsOK = False selectionChangedTaskResult.ShowMessageBox = True 'Launch data management sequence Dim customSubstVars As New Dictionary(Of String, String) 'You can use this dictionary to pass on parameters to your DM Sequence Dim objTaskActivityItem As TaskActivityItem = BRApi.Utilities.ExecuteDataMgmtSequence(si, "Workflow EPU Process IFRS", customSubstVars) objTaskActivityItem = BRApi.TaskActivity.GetTaskActivityItem(si, objTaskActivityItem.UniqueID) If (objTaskActivityItem.HasError) Then ' -- If there were errors selectionChangedTaskResult.Message = "Process completed with errors." Return selectionChangedTaskResult Else ' -- If DM sequence runs ok selectionChangedTaskResult.IsOK = True selectionChangedTaskResult.Message = "Process has completed successfully." ' You can paste and adapt your existing WF Status Update code here Return selectionChangedTaskResult End If End IfI hope this helps.
Thanks,
Fred
YanSavinsky
2 years agoNew Contributor III
As promised, here is the complete Dashboard Extender rule that is now being launched from the dashboard button.
I do have another issue manifest itself: lines 40 - 46 in the below sample are there to terminate the business rule if the DM sequence does not complete successfully. It does not work. I made my DM sequence error out during various steps and the condition of " If (objTaskActivityItem.HasError) Then ' -- If DM Sequence generates errors " is not being triggered. I can see entries being generated in the error log.
Namespace OneStream.BusinessRule.DashboardExtender.EPU_SolutionHelper
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardExtenderArgs) As Object
Try
Select Case args.FunctionType
Case Is = DashboardExtenderFunctionType.ComponentSelectionChanged
If (args.FunctionName.XFEqualsIgnoreCase("ExecuteEPUProcess")) Then
Dim wfProfileKey As Guid = si.WorkflowClusterPk.ProfileKey
Dim wfProfile As String = BRApi.Workflow.Metadata.GetProfile(si, si.WorkflowClusterPk.ProfileKey).Name
Dim scenario As String = ScenarioDimHelper.GetNameFromID(si, si.WorkflowClusterPk.ScenarioKey)
Dim time As String = BRApi.Finance.Time.GetNameFromId(si, si.WorkflowClusterPk.TimeKey)
Dim wfToUpdate As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, wfProfile, scenario, time)
Dim wfStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, si.WorkflowClusterPk, True)
Dim calcEntity As String = BRApi.Dashboards.Parameters.GetLiteralParameterValue(si,"False","WFEPUEntity")
Dim EPU_DM_Sequence As String = args.NameValuePairs.XFGetValue("EPU_DM_Sequence", Nothing)
Dim EPU_Entity_Selection_S4 As String = args.Namevaluepairs.XFGetValue("EPU_Entity_Selection_S4",Nothing)
Dim EPU_Period As String = args.Namevaluepairs.XFGetValue("EPU_Period",Nothing)
'Make sure the Workflow is not Complete or Locked before proceeding with DM Sequence
If (wfStatus.Locked)
Throw New System.Exception ("EPU Process could not be executed. EPU Workflow Step is locked.")
Else If wfStatus.GetOverallStatus().Equals(WorkflowStatusTypes.Completed)
Throw New System.Exception ("EPU Process could not be executed. EPU Workflow Step is complete.")
End If
Dim selectionChangedTaskResult As New XFSelectionChangedTaskResult()
selectionChangedTaskResult.IsOK = False
selectionChangedTaskResult.ShowMessageBox = True
'Launch data management sequence
Dim customSubstVars As New Dictionary(Of String, String) 'You can use this dictionary to pass on parameters to your DM Sequence
customSubstVars.Add("EPU_Entity_Selection_S4", EPU_Entity_Selection_S4)
customSubstVars.Add("EPU_Period", EPU_Period)
Dim objTaskActivityItem As TaskActivityItem = BRApi.Utilities.ExecuteDataMgmtSequence(si, EPU_DM_Sequence, customSubstVars)
If (objTaskActivityItem.HasError) Then ' -- If DM Sequence generates errors
selectionChangedTaskResult.Message = "EPU Process completed with errors."
Return selectionChangedTaskResult
Else ' -- If DM Sequence completes successfully
selectionChangedTaskResult.IsOK = True
selectionChangedTaskResult.Message = "EPU Process has completed successfully."
'Define Workflow Profile
'Complete the workflow step if and when DM sequence completes sucessfully
BRApi.Workflow.Status.SetWorkflowStatus(si, wfToUpdate, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, "Auto completing Workspace", _
"Error autocompleting Workspace", "Auto completing", Nothing)
' You can paste and adapt your existing WF Status Update code here
selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
selectionChangedTaskResult.IsOK = True
Return selectionChangedTaskResult
End If
End If
End Select
Return Nothing
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace
- FredLucas2 years ago
OneStream Employee
Thanks for sharing your solution YanSavinsky
I believe the error will get fixed if you add the following code to line 39:
objTaskActivityItem = BRApi.TaskActivity.GetTaskActivityItem(si, objTaskActivityItem.UniqueID)
Apologies for missing that statement in my original post, will edit not to confuse other people 🙂
Hope this helps.
- Pawel2 years agoNew Contributor II
Hello gentlemen,
I struggle with quite similar issue, the button executes the Dashboard Extender rule, it starts the DM, waits for the end, i can see the result message but the application does not refresh
What could be wrong?
- FredLucas2 years ago
OneStream Employee
Hi Pawel
Can you share your code, have you included this last part at the end?
'Complete the workflow step if and when DM sequence completes sucessfully BRApi.Workflow.Status.SetWorkflowStatus(si, wfToUpdate, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, "Auto completing Workspace", _ "Error autocompleting Workspace", "Auto completing", Nothing) ' You can paste and adapt your existing WF Status Update code here selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True selectionChangedTaskResult.IsOK = True Return selectionChangedTaskResult- Pawel2 years agoNew Contributor II
That was the final piece I was missing! Thank you!
Related Content
- 2 years ago
- 1 year ago