Forum Discussion
Hi Sam,
Appreciate your help! I am not modifying the bound parameter in GetDynamicComponentsForDynamicDashboard method. If I modify the bound parameter name, then I don't retrieve any parameters in the GetDynamicParametersForDynamicComponent method when using api.GetDynamicParametersForDynamicComponent.
Public Function GetDynamicParametersForDynamicComponent( _
ByVal si As SessionInfo,
ByVal api As IWsasDynamicDashboardsApiV800,
ByVal workspace As DashboardWorkspace,
ByVal maintUnit As DashboardMaintUnit,
ByVal dynamicComponentEx As WsDynamicComponentEx,
ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) _
As WsDynamicParameterCollection Implements IWsasDynamicDashboardsV800.GetDynamicParametersForDynamicComponent
Try
If api Is Nothing Then Return Nothing
Dim CompName As String = dynamicComponentEx.DynamicComponent.Component.Name
Dim params As WsDynamicParameterCollection = api.GetDynamicParametersForDynamicComponent( _
si,workspace,dynamicComponentEx,String.empty,Nothing,tristatebool.TrueValue,WsDynamicItemStateType.Unknown)
Dim paramname As String = Nothing
If CompName.Contains("CBX_Credits") Then
paramname = "par_CreditList"
Else
paramname = "par_DebitList"
End If
Dim ParamColl As New List(Of WsDynamicCompParamMemberEx)
Dim ParamComp As WsDynamicCompParamMemberEx = params.GetParameterUsingBasedOnName(paramname)
ParamComp.DynamicParameterEx.DynamicParameter.Parameter.Name = _
dynamicComponentEx.DynamicComponent.Component.BoundParameterName
ParamColl.Add(ParamComp)
Return New WsDynamicParameterCollection(dynamicComponentEx,ParamColl)
Catch ex As Exception
Throw ErrorHandler.LogWrite(si, New XFException(si, ex))
End Try
End FunctionWhen logging the bound parameter of dynamicComponentEx within GetDynamicParametersForDynamicComponent, it is no longer the stored name, it is par_DebitList_dynamic_Dyn_2.
The components are returned based off the parameter par_Entries_Count, which is initially set during the Load Dash Service. When the Load Dash service is executed, GetDynamicComponentsForDynamicDashboard is being executed twice. On the first run, customSubstVarsAlreadyResolved holds the par_Entries_Count value that was set in the load rule. On the 2nd execution, customSubstVarsAlreadyResolved has par_Entries_Count and literal formatting parameters from other components in the dashboard. At this point everything is behaving as expected.
When the dashboard is refreshed by changing the combo box associated with par_Entries_Count, GetDynamicComponentsForDynamicDashboard is being executed twice. The first time, customSubstVarsAlreadyResolved is empty, and the 2nd time has all the parameters like the 2nd load dash execution. The combo boxes are rendering the correct count, but the parameters are not retained. If I only Refresh using a button and not change par_Entries_Count, I still have the same issue. It seems like if customSubstVarsAlreadyResolved was not empty, the issue would be resolved.
Below is my code for the GetDynamicComponentsForDynamicDashboard method.
Public Function GetDynamicComponentsForDynamicDashboard(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace, _
ByVal maintUnit As DashboardMaintUnit, ByVal dynamicDashboardEx As WsDynamicDashboardEx, ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) _
As WsDynamicComponentCollection Implements IWsasDynamicDashboardsV800.GetDynamicComponentsForDynamicDashboard
Try
If (api IsNot Nothing) Then
If dynamicDashboardEx.DynamicDashboard.Name.StartsWith("0_Content_EntryDialog_Comps") Then
Dim Vars As New Text.StringBuilder
For Each var In customSubstVarsAlreadyResolved
Vars.AppendLine($"Key: {var.Key} Value: {var.Value}")
Next
brapi.ErrorLog.LogMessage(si,"DashName: " & dynamicDashboardEx.DynamicDashboard.Dashboard.Name _
& vbCrLf & Vars.ToString)
Return Me.GetMemberComponents(si,api,workspace,maintUnit,dynamicDashboardEx,customSubstVarsAlreadyResolved)
Else
Return api.GetDynamicComponentsForDynamicDashboard(si, workspace, dynamicDashboardEx, String.Empty, Nothing, TriStateBool.TrueValue, WsDynamicItemStateType.MinimalWithTemplateParameters)
End If
End If
Return Nothing
Catch ex As Exception
Throw New XFException(si, ex)
End Try
End Function
Public Function GetMemberComponents(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace, _
ByVal maintUnit As DashboardMaintUnit, ByVal dynamicDashboardEx As WsDynamicDashboardEx, ByVal customSubstVarsAlreadyResolved As Dictionary(Of String, String)) _
As WsDynamicComponentCollection
Dim wsDynCompMembers As New List(Of WsDynamicDbrdCompMemberEx)()
Dim CompCount As Integer = 0
For Each var In customSubstVarsAlreadyResolved
If var.Key = "par_Entries_Count" Then
CompCount = var.Value
End If
Next
For i As Integer = 1 To CompCount
Dim compName As String = Nothing
If dynamicDashboardEx.DynamicDashboard.Dashboard.Name = "0_Content_EntryDialog_Comps_Credits" Then
compName = "CBX_Credits"
Else
compName = "CBX_Debits"
End If
Dim wsDynCompMemberEx = BuildDynamicComponentFromStoredComponent(
si, api, workspace, maintUnit, dynamicDashboardEx,
compName, "Dyn_" & i, Nothing, WsDynamicItemStateType.EntireObject
)
If wsDynCompMemberEx IsNot Nothing Then
Dim comp = wsDynCompMemberEx.DynamicComponentEx.DynamicComponent.Component
' brapi.ErrorLog.LogMessage(si, "Comp Bound param name: " & comp.BoundParameterName)
wsDynCompMembers.Add(wsDynCompMemberEx)
End If
Next
Return New WsDynamicComponentCollection(dynamicDashboardEx, wsDynCompMembers)
End Function
Private Function BuildDynamicComponentFromStoredComponent(ByVal si As SessionInfo, ByVal api As IWsasDynamicDashboardsApiV800, ByVal workspace As DashboardWorkspace,
ByVal maintUnit As DashboardMaintUnit, ByVal dynamicDashboardEx As WsDynamicDashboardEx,
ByVal storedComponentName As String, ByVal nextLevelNameSuffixToAdd As String,
ByVal nextLevelTemplateSubstVarsToAdd As Dictionary(Of String, String),
ByVal dynamicItemStateType As WsDynamicItemStateType) As WsDynamicDbrdCompMemberEx
Dim storedComp = api.GetStoredComponentForDynamicDashboard(si,workspace,dynamicDashboardEx.DynamicDashboard, storedComponentName)
If storedComp IsNot Nothing Then
Dim wsDynamicCompEx = api.GetDynamicComponentForDynamicDashboard(si, workspace, dynamicDashboardEx, storedComp.Component, nextLevelNameSuffixToAdd, nextLevelTemplateSubstVarsToAdd, TriStateBool.TrueValue, dynamicItemStateType)
If wsDynamicCompEx IsNot Nothing Then
Dim wsDynCompMember As New WsDynamicDbrdCompMember()
Return New WsDynamicDbrdCompMemberEx(wsDynCompMember, wsDynamicCompEx)
End If
End If
Return Nothing
End Function Thanks again,
Ben
Hi BenEppel
What are you actually trying to achieve with the dynamic parameters?
It's not too clear based on your description
Are you trying to duplicate base parameter(s) that exist (not changing anything about them) and provide unique bound parameter names to your components based on this?
Or something else
Sam
- sameburn6 days ago
OneStream Employee
Hi BenEppel
If your issue is that you want to duplicate a parameter and give it unique names per instance (option 1), then you need to set the bound parameter of the dynamic component to be the dynamic parameter name e.g. "par_CreditList_dynamic_1" and then set your logic for that parameter in the GetDynamicParametersForDynamicComponent method of the service e.g. something like this.... where you actually define the parameter and what it does in the method.
// Retrieve wsDynamicParamCollection WsDynamicParameterCollection parameterCollection = api.GetDynamicParametersForDynamicComponent(si, workspace, dynamicComponentEx, string.Empty, repeatArgs.NextLevelTemplateSubstVarsToAdd, TriStateBool.TrueValue, WsDynamicItemStateType.MinimalWithTemplateParameters); // check objects exist if ((parameterCollection.Parameters != null) && (customSubstVarsAlreadyResolved != null)) { // Create dynamic parameter from stored parameter prm_SelectCubeName WsDynamicCompParamMemberEx newParameter = parameterCollection.GetParameterUsingBasedOnName("prm_SelectCubeName"); // Check parameter is not null using null-conditional operator if (newParameter?.DynamicParameterEx?.DynamicParameter?.Parameter != null) { // Change prm_SelectCubeName from a bound list to a delimited list newParameter.DynamicParameterEx.DynamicParameter.Parameter.ParameterType = DashboardParamType.DelimitedList; // Update Display and Value items for new parameter newParameter.DynamicParameterEx.DynamicParameter.Parameter.DisplayItems = "These,Are,New,Values"; newParameter.DynamicParameterEx.DynamicParameter.Parameter.ValueItems = "These,Are,New,Values"; } }Otherwise you have a conflict e.g. you are spawning new dynamic parameter names that are no longer related to your base parameter(s) or the bound parameters set on your component. I believe this explains the behaviour you are seeing where your parameters do not appear to be bound.
If you take an approach like above, you can use 1 stored parameter to create all of your dynamic parameters for Debit and Credit. The key is that you (a) define the dynamic parameters and (b) set the dynamic parameter name(s) you are expecting to return on your dynamic component(s) consistently
Hope this helps
Sam
- sameburn2 days ago
OneStream Employee
Hi BenEppel
Were you able to resolve your issue?
One of the best ways to approach dynamic dashboards is to use the RepeatArgsList to do the heavy lifting. This can significantly reduce the amount of code required for each method and maintains consistency between methods...
There are some Tech Talks that talk through Dynamic Dashboards setup and content, that you might also find useful, on this subject. I also wrote a very simple example blog post here that shows how to construct repeat arguments using List<WsDynamicComponentRepeatArgs>.
Dynamic Dashboards – Passing Parameters with Repeat Arguments. | OneStream Community
Hope this helps
Sam
Related Content
- 3 years ago