Complete/Revert Workflow BR

SamKing
New Contributor II

Hi All,

We're running into a few problems with an existing BR that is used to change the state of the current workflow. The current BR is used in the admin workflow & we haven't encountered any problems, however when end users attempt to run this rule on a child workflow, they receive the error message below.

SamKing_0-1670005164065.png

Business Rule
If args.FunctionName.XFEqualsIgnoreCase("WorkflowStatusUpdate") Then

Dim strChangeType As String = args.NameValuePairs.XFGetValue("ChangeType")
Dim selectionChangedTaskResult As XFSelectionChangedTaskResult = Me.WorkflowStatusUpdate(si, strChangeType)

Return selectionChangedTaskResult
End If

When an admin progresses the workflow the end users are able to execute the subsequent steps to complete their workflow. Is there something I'm missing in the current rule that needs to be changed or is this an issue with our security setup?

Thanks,

4 REPLIES 4

JackLacava
Honored Contributor

Your "me.WorkflowStatusUpdate" call means you have custom code in a function "WorkflowStatusUpdate", further down (or up) in the same business rule file. In that function you might have code that is tripping up the security setup, you might want to post it here for review. Either that, or the specific user really has no access to that workflow at all.

SamKing
New Contributor II

The complete business rule can be found below.

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.LoadDashboard

Case Is = DashboardExtenderFunctionType.ComponentSelectionChanged
If args.FunctionName.XFEqualsIgnoreCase("SetAssignedEntity") Then
Brapi.State.SetUserState(si,False,ClientModuletype.Windows,String.Empty, String.Empty, "ParamComboEntity",String.Empty,args.NameValuePairs("AssignedEntity"),Nothing)
'brapi.ErrorLog.LogMessage(si,"PAram Value - " & args.NameValuePairs("AssignedEntity"))
End If

'-------------------------------------------------
'Complete or Revert Workflow
'-------------------------------------------------
If args.FunctionName.XFEqualsIgnoreCase("WorkflowStatusUpdate") Then
Dim strChangeType As String = args.NameValuePairs.XFGetValue("ChangeType")
Dim selectionChangedTaskResult As XFSelectionChangedTaskResult = Me.WorkflowStatusUpdate(si, strChangeType)

Return selectionChangedTaskResult
End If

End Select

On further investigation users with access to the immediate parent workflow are able to execute this business rule for the child workflow. However, if a user only has access to the workflow in question, they're unable to execute the rule.

JackLacava
Honored Contributor

Sam, sorry, that's still not the actual full rule. The rule class by default does not have a WorkflowStatusUpdate method:

JackLacava_0-1670348651654.png

There must be a block somewhere else, with "Function WorkflowStatusUpdate" or "Sub WorkflowStatusUpdate", where that call is defined, or the rule is doing some other funky import magic to pull that method into its namespace.

Without seeing what that function does, we can't know what's going on.

 

OSPhilly88
New Contributor II

The issue is most likely the business rule trying to access the parent workflow to check the workflow status.  If you have a security setting on the parent workflow that the end user does not have access the rule will not work in this scenario.

 

Here is a generic workspace helper:

 

Namespace OneStream.BusinessRule.DashboardExtender._WATSCO_Workspace_Helper
Public Class MainClass
Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardExtenderArgs) As XFSelectionChangedTaskResult
Try
	Dim selectionChangedTaskResult As New XFSelectionChangedTaskResult()
	'Define Workflow Profile
	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)
	If args.FunctionName.XFEqualsIgnoreCase("WorkflowComplete") Then
		'Used to complete a workspace
		Dim wfClusterPK As WorkflowUnitClusterPk = BRApi.Workflow.General.GetWorkflowUnitClusterPk(si, _
			wfProfile, scenario, time)
		BRApi.Workflow.Status.SetWorkflowStatus(si, _
			wfClusterPK, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, _
			"Workspace Completed", "", "User clicked complete workflow", Guid.Empty)
		'Used to update the wfstatus automatically
		selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
		selectionChangedTaskResult.IsOK = True
		selectionChangedTaskResult.ShowMessageBox = True
		Return selectionChangedTaskResult

	Else If args.FunctionName.XFEqualsIgnoreCase("WorkflowRevert") Then
		'Used to revert a workspace
		BRApi.Workflow.Status.SetWorkflowStatus(si, _
			si.WorkflowClusterPk, StepClassificationTypes.Workspace, WorkflowStatusTypes.InProcess, _
			"Workspace Reverted", "", "User clicked Revert workflow", Guid.Empty)
		selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
		selectionChangedTaskResult.IsOK = True
		selectionChangedTaskResult.ShowMessageBox = True
		Return selectionChangedTaskResult
	End If

	Return Nothing
Catch ex As Exception
	Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End Function
End Class
End Namespace