Skip to main content
March 23, 2022

Dashboard Extender Rules - GetUserState / SetUserState Setup / Examples

  • March 23, 2022
  • 2 replies
  • 0 views

We would like to get the POV that a user set in a Dashboard (through Form Templates) and apply it to each other dashboards that they go into. We use to call this a "Sticky POV".

Currently, dashboards will hold the POV from the last time a user was in each dashboard. We want to carry the most recent POV into all dashboards.

Does anyone have examples or know how to set this up / use it / access it...?

Thanks in advance.

 

2 replies

March 24, 2022

You can add a selection changed code to set the user state

BRApi.State.SetUserState(si, False, ClientModuleType.Windows,"","","POV","","Value", Nothing)

Now on the dashboard launch event do a GetUserState

'Get the state value	
dim stateValue as string = String.empty			
				Dim userState As XFUserState = BRApi.State.GetUserState(si, False, ClientModuleType.Windows, String.Empty, String.Empty, stateKey, String.Empty)					
				If Not userState Is Nothing Then
					stateValue = userState.TextValue
				End If	

 and add the value to the modifiedcustomsubstvars.

loadDashboardTaskResult.ModifiedCustomSubstVars.Add("ParamName", stateValue)

October 22, 2024

How do we reset the userState?

We are able to use GetUserState and SetUserState , but the next time- GetUserState is triggered, it does not pick the latest parameters , but uses the last time, it was used.  

We are trying something like below but getting an error.

"Tr_wfName","Tr_wfScenario" and "Tr_wfTime" are parameters defined in the dashboard.

BRApi.State.SetUserState(si, false, ClientModuleType.Windows,"","","Tr_wfName","", "", null);
 BRApi.State.SetUserState(si, false, ClientModuleType.Windows,"","","Tr_wfScenario","", "", null);
 BRApi.State.SetUserState(si, false, ClientModuleType.Windows,"","","Tr_wfTime","", "", null);
 
October 23, 2024

You need to pass the value, not the parameter, also you need at least one key to get it back.