Forum Discussion

royceBPSC's avatar
royceBPSC
New Contributor II
4 years ago

WFProfileEntities Dropdown Menu Order

Hi everyone,  I have a cube view that uses an entity parameter with member filter E#Root.WFProfileEntities for users to select their respective workflow entities when opening the cube view. However...
  • NickKroppe's avatar
    4 years ago

    Hi,

    This question is answered in an existing KB article that recently expired and is in the final stages of being re-published. Here is a possible solution pulled from the KB article that uses a dashboard dataset rule to execute the WF method query and sort the results. This concept can be applied any time you want to sort the results of a OneStream method query or really any data table for that  matter. Lastly, this same topic is covered in the OneStream Foundation Handbook in the rules chapter and can be found on page 230.

     

    Namespace OneStream.BusinessRule.DashboardDataSet.WFAssignedEntityQuery
    	Public Class MainClass
    		Public Function Main(ByVal si As SessionInfo, ByVal globals As BRGlobals, ByVal api As Object, ByVal args As DashboardDataSetArgs) As Object
    			Try
    				Select Case args.FunctionType					
    					Case Is = DashboardDataSetFunctionType.GetDataSet
    						If args.DataSetName.XFEqualsIgnoreCase("SortedWFEntities") Then
    							'Open DB connection and execute the method command
    							Dim ds As DataSet = Nothing
    							Using dbConnApp As DbConnInfo = BRAPi.Database.CreateApplicationDbConnInfo(si)				
    								'Execute the Method Command
    								ds = BRAPi.Database.ExecuteMethodCommand(dbConnApp, XFCommandMethodTypeId.WorkflowProfileEntities,"","WF", Nothing)
    							End Using					
    							'massage the data table
    							If (Not ds Is Nothing) Then
    								If ds.Tables.Count > 0 Then
    									'Get the data table
    									Dim dt As DataTable = ds.Tables(0).Copy()
    									'Create new data view to sort the results by a given field in the table
    									Dim dataView As New DataView(dt)
    									'sort by the name field in an ascending manner
    									dataView.Sort = "Name Asc"
    									Dim sortedDT As DataTable = DataView.ToTable()
    									sortedDT.TableName = "SortedAssignedEntities"
    									Return sortedDT
    								Else
    									BRAPi.ErrorLog.LogMessage(si, "There are no entities assigned to the workflow")
    								End If
    							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

     

     

    Nick Kroppe

    OneStream Software