Skip to main content
July 2, 2025
Solved

getLiteralParameterValue in a KPI formula

  • July 2, 2025
  • 2 replies
  • 0 views

I would like to use a parameter value in a KPI in my API_Calculate business rule.

I have a literal value parameter and we will change the default value ahead of time to control which formula runs. I'm trying to pull the current default value with the following:

Dim param As String = BRApi.Dashboards.Parameters.GetLiteralParameterValue(si, False, Nothing, "myFlag")

When it gets to that line it throws a "Object reference not set to an instance of an object". 

Any ideas?

Best answer by DanielWillis

Have you tried putting the workspace in?

2 replies

Employee
July 3, 2025

Have you tried putting the workspace in?

July 3, 2025

As DanielWillis​ has mentioned, you cannot pass Nothing(null) as an argument for the Workspace Guid parameter in GetLiteralParameterValue.  Instead pass in the workspace id of the workspace where your parameter lives.

At a minimum you need something like this:

Dim workspaceId As Guid = BRApi.Dashboards.Workspaces.GetWorkspaceIDFromName(si, False, "Your Workspace Name")
Dim myFlagValue As String = If(BRApi.Dashboards.Parameters.GetLiteralParameterValue(si, False, workspaceId , "myFlag"), "")

 

JuleneDSAuthor
July 9, 2025

We set up all our dashboard under "Default" workspace. Using just your first line with "Default" and I'm still getting the same error. (I saw in another thread someone using Nothing or GUID.empty for the default which is why I tried that.) 

July 9, 2025

Please post your code, could be something else causing the error.

The id of the default workspace is the same as Guid.Empty ('00000000-0000-0000-0000-000000000000') , so that would work.
You can use:
New Guid()
Guid.Empty
Nothing

they all do the same thing in vb.  If you are still getting the null pointer error, then its something else in your code.

Its helpful to use null coalescence in cases where unexpected nulls may cause the null pointer error, "Object not set to a reference of an object", to happen