Dynamically disable button on a dashboard

New Contributor III

Is there a way to set the property of a dashboard button to disabled?  I have a dashboard that includes a number of button objects that execute various tasks, such as running a calculation, locking the workflow and so forth.  What I'd like to be able to do is to disable a button as part of a business rule so that the user has to follow a sequence of activities and can't, for example, keep pressing the calculate button on the dashboard. I don't see any property in the button object that supports enabled/disabled.


Contributor III

The best alternative at this time is to use a boolean operator on the IsVisible property, it is either Visible or not based on some property.  i.e. their Security Group or if they are an Admin or not.  You can dynamically make the button visible or not visible based on some condition.  Another alternative is you could do an Exception window that halts the process based on some condition, i.e. CalcStatus is OK so do not calculate (not needed).  There is no disable/enable option.

Contributor III

This is an example of IsVisible from the OneStream People Planning Solution - it is a condition check to Show/Hide the button if the user is an Admin.


Function in XFBR String rule:


That will return the Boolean True/False.  So the button is hidden from Non-Admins.  That BRApi call is a packaged OS function.  They are pretty cool like that in that common functions are packaged and standard.  You could hijack this methodology and do whatever condition statement you need to hide it. 

I'll also paste code here so you could do an exception window if that helps.

New Contributor III

That's really helpful, thanks MikeG

Contributor III

If the Workflow is in a Completed status, you could do a dynamic XFBR string rule and return isVisible = False on your actionable buttons.  i.e. when the Workflow if Reverted the buttons are IsVisible = True.

Valued Contributor

@ianreid  while you cannot 'disable' the buttons, what you can do is create a parameter for each button 
e.g. pm_btn_RunCalc_isEnabled
Then in the dashboard extender code where you would "disable" the button specify:
taskResult.ModifiedCustomSubstVars.Add("pm_btn_RunCalc_isEnabled", "False")

taskResult.ModifiedCustomSubstVars.Add("pm_btn_RunCalc_TextColor", "XFLightGray ")

taskResult.ModifiedCustomSubstVars.Add("pm_btn_RunCalc_isEnabled", "True")

taskResult.ModifiedCustomSubstVars.Add("pm_btn_RunCalc_TextColor", "#FF000000 ")

In the Selection Changed Server Task Arguments for the button, add to the third set of {} braces:
{IsEnabled=|!pm_btn_RunCalc_isEnabled!| ...<other params>}
Then in the dashboard extender code that handles the button click for the param you just set:

If args.NameValuePairs("IsEnabled", String.Empty).Equals("True") Then
    <call to function or sub that runs your calc>
End IF

This was if IsEnabled = False (or anything other than "True"), the Dashboard Extender will exist without doing anthing, giving the appearance of a diabled button.

You can use parameters the same way to change the format of the button to use black when "enabled" and XFLightGray when not enabled.  Display Format: TextColor=|!pm_btn_RunCalc_TextColor!|

Parameters give you all the flexibility you need to accomplish this.