I'm using a BUTTON in ExpBuilder to reference a URL link in an attribute field for the selected feature. If the field is BLANK (i.e. does not contain a hyperlink) I would like to either hide/disable the button OR display some alternate text (i.e. "No content for this feature"). Otherwise the button just doesn't do anything at all when the user clicks it, which could be confusing. Any way to do this?
When you connect a button widget to a data source, you can also use Attribute or Expression for the button text.
You can use the Expression and change the expression title to no data message.
Regards,
Shengdi
Update. This is still a problem. I have a button that goes to an EXB window. I don't want to open that window if there is no active selection, because there will be no data to display in the window (and the format is too complicated to replace it all with an expression that has a default message for no data). I would love to restrict it so that there is always a selection, then the button could always open the window, but because of a different issue, the user can always simply click on the map which clears the selection, thus setting the selection to nothing.
I will put in an "idea" about it.
I guess if I had a field that contained text useful as a button label that would work, but that isn't my situation. And still, that doesn't really disable the button, which would be preferable.
If I could put some useful logic in that button Expression along the lines of: IIf (IsEmpty($feature.field1), "No Data", "Click Me"), where I'm using field1 to store a URL used by SetLink, that would be closer to useful. But it looks like the Expression box won't take Arcade expressions(?).
My alternate solution was to leave the button as-is and instead set a default value for the field SetLink refers to. This default value is a URL that points to a web page that displays a "No data for this feature" message. So the button only functions meaningfully if the editor replaces the default value with a good URL. In my case, the good URL points to a Survey123 form.
this is still an issue... come on, ESRI, roll those sleeves up. How is opening a new window the default behaviour when there's no data connected?
I heard it said in a UC technical presentation at the end during the questions section that Arcade would be integrated into ExB soon. I am hoping that the conditional and formatting features of Arcade would give us what we need for this problem.
I have finally upgraded to the latest (1.15) version of Developer Edition and now have an up to date version of my workaround to share (attached). It is a copy of Esri's Button widget where I added a separate (3rd) style in the settings for cases where there is no URL in the data (data value does not start with http). It is specifically for use in a List widget, but could likely be tweaked for use outside of Lists. I do not plan to upgrade it beyond v1.15.
One potential (but not ideal) workaround we have tried is to use the list widget. The list widget does disappear if there is no data so essentially you put the button in the list to utilize this functionality.
The steps: Create a new table with fields just for the URLs and a key to connect it to the original table. Add a list widget and connect it to this new table's selected features. Include a button on the list entries and set the button settings as you would usually (open a window, go to URL, etc.). Use the list formatting/sizing options to hide all but the first list entry. Use the key field and actions to connect by selection the original table and the new table (the one with just the URLs that is in the list). Now when a user selects a feature, the button should only appear if there is corresponding data in the URL table. Otherwise, the list will show no data.
If you don't want the "no data" text to appear, you could either change the no data message text to just a space (still shows a caution sign) or you could also increase the size of the list and strategically use text boxes and layering to cover it up.
This workaround has its limitations and is admittedly cumbersome. It requires creating a whole new table and going through many formatting steps. But it could be a potential option until Arcade or something else is available to use in Experience Builder and if you do not have Developer Edition.