Complete/Revert buttons - Dashboard extender workflow access
Hi, I am facing an issue with a dashboard extender rule, in the bit of code that Completes or Revert the workflow and is called by the Complete and Revert buttons of the dashboard.
For example, this is the Revert function:
Public Function WorkflowRevert(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal wfClusterPK As WorkflowUnitClusterPk) As XFSelectionChangedTaskResult
Try
Dim selectionChangedTaskResult As New XFSelectionChangedTaskResult()
'Check the Workflow status of the parent (We can't calculate plan if the parent is certified)
Dim wfRegParent As WorkflowProfileInfo = BRApi.Workflow.Metadata.GetParent(si, wfClusterPK)
Dim wfRegParentPk As New WorkflowUnitClusterPk(wfRegParent.ProfileKey, wfClusterPK.ScenarioKey, wfClusterPK.TimeKey)
Dim wfRegParentStatus As WorkflowInfo = BRApi.Workflow.Status.GetWorkflowStatus(si, wfRegParentPk, False)
If Not wfRegParentStatus.AllTasksCompleted Then
'PROCESS INDIVIDUAL SOLUTION WORKFLOWS
'-------------------------------------
'Update the Workflow to COMPLETED
Dim wfClusterDesc As String = BRApi.Workflow.General.GetWorkflowUnitClusterPkDescription(si, wfClusterPK)
BRApi.Workflow.Status.SetWorkflowStatus(si, wfClusterPK, StepClassificationTypes.Workspace, WorkflowStatusTypes.InProcess, StringHelper.FormatMessage(Me.m_MsgWorkflowReverted, wfClusterDesc), "", Me.m_MsgWorkflowRevertedReasonButton, Guid.Empty)
'BRApi.Workflow.Status.SetWorkflowStatus(si, wfPk, StepClassificationTypes.Workspace, WorkflowStatusTypes.Completed, StringHelper.FormatMessage(Me.m_MsgWorkflowCompleted, wfClusterDesc), "", Me.m_MsgWorkflowCompletedReasonButton, Guid.Empty)
selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = True
selectionChangedTaskResult.IsOK = True
Else
'If Not wfRegParentStatus.AllTasksCompleted Then
'Parent Certified, cannot update Workflow
selectionChangedTaskResult.WorkflowWasChangedByBusinessRule = False
selectionChangedTaskResult.IsOK = True
selectionChangedTaskResult.ShowMessageBox = True
selectionChangedTaskResult.Message = Me.m_MsgCannotCompleteWorkflow
End If
Return selectionChangedTaskResult
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End FunctionThe code is checking the parent workflow, so that if the parent workflow is completed the user is not allowed to revert the the workflow. The issue is that some users don’t have access to the parent workflow, and this is the error message they get when trying to revert the workflow:

Is there any workaround to this issue? It seems a bit silly that the code would not even check the status of the parent workflow if the user does not have access to it.
Is there a way to run some code lines as admins? For example by grabbing the SessionInfo (si) of an Admin (just thinking out loud, I am not sure how to do that)?

