Forum Discussion

JuleneDS's avatar
JuleneDS
New Contributor II
2 days ago

getLiteralParameterValue in a KPI formula

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?

2 Replies

  • RobbSalzmann's avatar
    RobbSalzmann
    Valued Contributor II

    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 param As String = BRApi.Dashboards.Parameters.GetLiteralParameterValue(si, False, workspaceId , "myFlag")