Dashboard: Get/Set Labels on Dashboard

jacktemplinjr
New Contributor

Is there a way to get the list of components on the calling dashboard on load?

Trying to use:
args.ComponentInfo.Component.Name results in nothing, even though I have multiple components on my dashboard.

I want to get a list of all components, particularly a label or 2, and based upon user settings/access/Text fields, set labels

1 ACCEPTED SOLUTION

JackLacava
Community Manager
Community Manager

args.ComponentInfo.Component represents the component that triggered the rule, which in your case (you're talking about "on load") is probably the Dashboard itself.

You have to switch the mindset around a bit: instead of pulling strings from centralized code, you set Parameters on the components' properties (e.g. in the Text property of a Label), and let widgets pick up actual values when they get drawn. You can call BRApi.Dashboards.Parameters.SetLiteralParameterValue from any code to change those values, for example when the dashboard loads (since it will do that before widgets, so Parameters will be populated before the Components are drawn); if you change a Parameter after the whole page was displayed, you will have to refresh the Dashboard containing affected widgets to see new values in action.

So for example, I have a parameter on my label here:

JackLacava_0-1673040167265.png

And then in a rule that runs on load, I set the parameter:

 

brapi.Dashboards.Parameters.SetLiteralParameterValue(si, False, "ST_Balance", newBalance)

 

View solution in original post

1 REPLY 1

JackLacava
Community Manager
Community Manager

args.ComponentInfo.Component represents the component that triggered the rule, which in your case (you're talking about "on load") is probably the Dashboard itself.

You have to switch the mindset around a bit: instead of pulling strings from centralized code, you set Parameters on the components' properties (e.g. in the Text property of a Label), and let widgets pick up actual values when they get drawn. You can call BRApi.Dashboards.Parameters.SetLiteralParameterValue from any code to change those values, for example when the dashboard loads (since it will do that before widgets, so Parameters will be populated before the Components are drawn); if you change a Parameter after the whole page was displayed, you will have to refresh the Dashboard containing affected widgets to see new values in action.

So for example, I have a parameter on my label here:

JackLacava_0-1673040167265.png

And then in a rule that runs on load, I set the parameter:

 

brapi.Dashboards.Parameters.SetLiteralParameterValue(si, False, "ST_Balance", newBalance)