Determine Workflow Profile Security Access in a Dashboard Extender Rule

ChrisR1chgov
New Contributor
I'm using the following code snippet in a Dashboard Extender Rule to loop through the list a of Workflow Profiles.  However, the code fails, if the user does not have security access to a particular Workflow Profile, returned in the list.  Is there a way I can get the list returned with security access applied, so the list only returns Workflow Profiles that the user has access to?
 
Dim profile As String = "text1 tag to match"
Dim wfProfileName As String = ""
Dim cubeRootInfo As WorkflowCubeRootInfo = BRApi.Workflow.Metadata.GetCubeRootInfo(si, si.WorkflowClusterPk.ProfileKey, True)
cubeRootCluster As New WorkflowUnitClusterPk(si.WorkflowClusterPk)
cubeRootCluster.ProfileKey = cubeRootInfo.CubeRootProfile.ProfileKey
Dim profileInfos As List(Of WorkflowProfileInfo) = BRApi.Workflow.Metadata.GetRelatives(si, cubeRootCluster, WorkflowProfileRelativeTypes.Descendants, WorkflowProfileTypes.BaseAndParentInputProfiles)
 
For Each profileInfo As WorkflowProfileInfo In profileInfos
Dim wfScenarioTypeID As Integer = BRApi.Workflow.General.GetScenarioTypeId(si, cubeRootCluster)
 
If profile = profileInfo.GetAttributeValue(WfScenarioTypeID,sharedconstants.WorkflowProfileAttributeIndexes.Text1)
wfProfileName = profileInfo.ToString
' brapi.ErrorLog.LogMessage(si," profileInfo.Name = " & profileInfo.ToString & " : Text1 = " & profileInfo.GetAttributeValue(WfScenarioTypeID,sharedconstants.WorkflowProfileAttributeIndexes.Text1))
End If
Next

 

1 REPLY 1

TheJonG
Contributor II

I do not believe there is a way to only return the profiles a user has access to. You would need to loop through the Profiles and bring in the AccessGroup and MaintenanceGroup IDs then check if the user is in that group using BRApi.Security.Authorization.IsUserInGroup(si, groupID). Before the loop create a new List (Of WorkflowProfileInfo) object and add the Workflow Profile Infos to it if the conditions are met.