Forum Discussion
Hi BenEppel
Are you setting "par_CreditList_dynamic_1", "par_DebitList_dynamic_2", etc on your dynamic component e.g. combobox in the GetDynamicComponentsForDynamicDashboard method?
Based on your description it looks like you might have a conflict between bound parameter name set on the component and the parameter name returned by the your logic? e.g. your dynamic component is not expecting "par_CreditList_dynamic_1" to be returned
Hope this helps
Sam
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
- sameburn2 days ago
OneStream Employee
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
Related Content
- 3 years ago