Hiding fields / Return default text for null fields in popupTemplate

1177
6
08-25-2020 07:58 AM
Claire_Peterson
Occasional Contributor

Is there a way to hide or display "Not Recorded" / "No Data" for fields that may be null in a popupTemplate? I have a few fields that are not required, thus containing nulls. I want to return a specific set of attributes from a query but depending on the resulting feature, these fields may be empty and I'd prefer to have some "filler text" versus having those sections of the popupTemplate be blank. I'd also like to hide a few fields from the popup if they are null (chemicals #2 & #3) I've seen some information on using Arcade IIF statements to set default values if the field is null but I get the impression that these statements can't be placed in the expressionInfos section of the popupTemplate?

Picture attached

6 Replies
MikeDolbow
New Contributor III

I'm researching the same thing today. Haven't figured it out yet but hopefully will post here if I do. Trying to work off:

Some of the comments after the AGOL blog are leading in me in good directions but not quite there. Have you figured it out yet?

0 Kudos
Claire_Peterson
Occasional Contributor

Mike Dolbow No luck yet I have been working off the same 3 examples but have not had any success. If I do find something that works I will certainly post it here!

luckachi
Occasional Contributor

Does anyone have any updates for this? diving back into this and still no success on how to set a default text if the field is null. Would rather show something like "Not Reported" / "No Data" instead of having it blank

0 Kudos
EdgardoIbarra
New Contributor

Hi, this worked for me:

This is the template
<tr style="display:{expression/origin};">
            <th class="esri-feature-fields__field-header">Origin</th>
            <td class="esri-feature-fields__field-data">{origin}</td>
</tr>
 
This is my expression
expressionInfos: [{
        name: "origin",
        expression: "IIf($feature.origin == null, 'none', 'table-row');"
}]
 
This is the rendered html
<tr style="display: none;">
        <th class="esri-feature-fields__field-header">Origin</th>
        <td class="esri-feature-fields__field-data"></td>
</tr>
 
luckachi
Occasional Contributor

Unfortunately it seems like Arcade expressions do not work in the standard popupTemplate which I was hoping to use versus creating an html table.

0 Kudos
luckachi
Occasional Contributor

It looks like in API 4.20 Arcade expressions can now be rendered in the popupTemplate. I am not sure if it matters but I have the expressionInfos at the end of my popupTemplate (after the content section). DefaultValue expression works correctly now :thumbs_up:

0 Kudos