Select to view content in your preferred language

Add a "Disabled" option for buttons

629
2
08-29-2024 02:02 PM
Status: Open
abureaux
MVP Frequent Contributor

The button widget can be connected to data. However, when a non-data source is selected, clicking the button (at least for me) opens a new tab with the web app. Meaning, you can essentially click the button 10 times, and get 10 copies of the web app open in your browsers.

A disabled option could be useful for situations where you connect data to a button. When a non-data source is selected, the button is "disabled". (And of course, actually disable the button so it doesn't do anything when it shouldn't do anything)

abureaux_0-1724965324003.png

 

2 Comments
JeffShaw

I have this issue when a button is configured to open a URL saved in an attribute field. When the field is populated, it opens the webpage in a new tab. But when the field value is null, it opens the current Experience Builder app in the new tab instead. It would be great if the button is instead disabled when the value is null. 

That's said, there's a LONG list of additional cases for why buttons should be disabled (e.g. empty recordset) but at present, there's no way to add logic to disable them or change their behavior. That's a fundamental need for any UI, and is STILL missing from ExB.  The klugey workaround I have used is to hide buttons by adding the button to a list and giving the list room to only display the top row's button. If the list's expression returns no values, the button disappears. BUT... it gets replaced by the no data warning icon which you can't currently remove. You can try to configure the list widget size so the icon doesn't appear, or cover it, but that often isn't possible.

Hopefully Arcade expressions will come to the rescue soon!!!!

DavidWittmann

I have the same issue that Jeff described – a Button widget that is bound to a dynamic URL opens the whole Experience Builder app when the source field is empty.
When no feature is selected (or the attribute used for the URL is null) the button should be inert, but today it simply launches a duplicate copy of the app in a new tab. This is confusing for users and makes the button unusable in many real‑world scenarios.
Even with the recent addition of Arcade support, there is currently no way (that I know of) to turn a Button widget on/off from an Arcade expression. Below is a short pseudocode sketch that shows the logic I would like to apply if the widget exposed an IsEnabled (or similar) property:

// ------------------------------------------------------------
// 0️⃣  Base URL – the part that is always required
// ------------------------------------------------------------
var BaseURL = "https://website.com/placeholder/Status?field=";

// ------------------------------------------------------------
// 1️⃣  Pull the selected features from the data source
// ------------------------------------------------------------
var ds               = $dataSources["dataSource_#-id-layer-#-selection"];
var selectedFeatures = ds.selectedFeatures;   // may be null / empty

// ------------------------------------------------------------
// 2️⃣  No selection → button should be disabled
// ------------------------------------------------------------
if (IsEmpty(selectedFeatures)) {
    // <-- Desired behaviour (not currently possible)
    // $button.IsEnabled = false;   // <-- Arcade does not expose this
    return "";                     // placeholder so the expression does not error
}

// ------------------------------------------------------------
// 3️⃣  At least one feature is selected – build the URL
// ------------------------------------------------------------
var firstFeature = First(selectedFeatures);
var fieldValue   = firstFeature.Field;   // the attribute that holds the key

// Guard against a null/empty attribute
if (IsEmpty(fieldValue)) {
    // $button.IsEnabled = false;   // <-- same limitation as above
    return "";
}

// ------------------------------------------------------------
// 4️⃣  Return a valid URL (the button will be enabled automatically)
// ------------------------------------------------------------
return BaseURL + UrlEncode(Text(fieldValue));