Forum Discussion

ChrisR1chgov's avatar
ChrisR1chgov
New Contributor
4 months ago

Determine Workflow Profile Security Access in a Dashboard Extender Rule

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

 

  • TheJonG's avatar
    TheJonG
    Contributor III

    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.

    • ChrisR1ch's avatar
      ChrisR1ch
      New Contributor III

      I'm having a problem getting a list of all workflow profiles, to be able to loop through and pull Access Group and Maintenance Group.  Can you give me or direct me to a snippet of code that will return that list.

      • KarlT's avatar
        KarlT
        Contributor III

        This function should help

        BRApi.Workflow.Metadata.GetRelatives(si, cubeRootCluster, WorkflowProfileRelativeTypes.Descendants, WorkflowProfileTypes.BaseAndParentInputProfiles)