Select to view content in your preferred language

Arcade Expr skips empty in MV Classic but not in New MV

2145
17
Jump to solution
02-23-2022 11:48 AM
RaenaDeMaris
Occasional Contributor

Greetings all.

I created a custom pop-up in MV Classic that includes values from 7 text attribute fields, plus up to 3 photos. 3 of the 7 fields are links to web pages, and I successfully configured the popup in Arcade to exclude rows with missing values for those 3 fields. (Sidebar: because the attributes with some missing values are links to web pages, I have not been able to figure out--despite exhaustive effort--how to collapse the resulting empty rows.) The popup worked well in MV classic and showed all of the text fields, with the photos at the bottom.

Here's the problem: I was requested to switch the order of the display such that it shows some text fields, then the media photos, and then the remaining text fields beneath that (for use in the feature information card in Web Experience Builder). When I re-order the popup info in new map viewer, the Arcade expression I used before loses functionality--all rows are displayed, even though they contain empty data, resulting in text that should be a link but doesn't have anything to link to, rather than a blank, empty line. The HTML that I try to copy over from old to new popup configuration fails. Below is a screen capture of the new popup and configuration in New MV, and following are my original Arcade expressions and the HTML in MV Classic that doesn't seem to translate in new MV.

What am I doing wrong?

RaenaDeMaris_0-1645645437873.png

Arcade expressions that worked in MV Classic (but returned a blank line if empty once formatted as links)

return IIF(IsEmpty($feature.Embeds), 'none', 'inline')

return IIF(IsEmpty($feature.Link1), 'none', 'inline')

The bottom attribute link is never empty, but the other two might be.

Thanks for any insights you can provide.

raena

rbd
0 Kudos
17 Replies
RaenaDeMaris
Occasional Contributor

@XanderBakker I greatly appreciate this help!! The HTML in that worked in MV Classic is below, with the part relevant to the three hyperlinks that I'm trying to troubleshoot in the blue text.

<div style="background-color:#{expression/expr8};padding:5px;">
<span style="color:#{expression/expr9};">
<strong>{CatDescrip}: {Organization}</strong>
</span>
</div>
<span style="display:{expression/expr1}">
<br />{VictoryTitle}<br />
</span><i><b><font color="#46C8F3"><br />{Pop} benefitted from the victory!</font></b>
<br /></i>
<span style="display:{expression/expr2}"><br />{VictDescrip}<br /> </span>
<br />
<span style="display:{expression/expr6}"><a href="{Embeds}" target="_blank">Visit the Victory's Media Page</a></span>
<br />
<span style="display:{expression/expr7}"><a href="{Link1}" target="_blank">Learn More About the Victory</a></span>
<br />
<a href="{Link2}" target="_blank">Go to Waterkeeper Website</a>

The relevant arcade expressions are:

(expression/expr6) = return IIF(IsEmpty($feature.Embeds), 'none', 'inline')

(expression/expr7)= return IIF(IsEmpty($feature.Link1), 'none', 'inline')

rbd
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @RaenaDeMaris ,

You would probably end up doing something like:

var expr1 = 'Include the result of expr1 here' // {expression/expr1}
var expr2 = 'Include the result of expr2 here' // {expression/expr2}
var expr8 = 'Include the result of expr8 here' // {expression/expr8}
var expr9 = 'Include the result of expr9 here' // {expression/expr9}

var html = '<div style="background-color:#' + expr8 + ';padding:5px;">';
html += TextFormatting.NewLine + '<span style="color:#' + expr9 + ';">';
html += TextFormatting.NewLine + '<strong>' + $feature.CatDescrip + ': ' + $feature.Organization + '</strong>';
html += TextFormatting.NewLine + '</span></div>';
html += TextFormatting.NewLine + '<span style="' + expr1 + '">';
html += TextFormatting.NewLine + '<br />' + $feature.VictoryTitle + '<br />';
html += TextFormatting.NewLine + '</span><i><b><font color="#46C8F3"><br />' + $feature.Pop + ' benefitted from the victory!</font></b>';
html += TextFormatting.NewLine + '<br /></i>';
html += TextFormatting.NewLine + '<span style="display:' + expr2 + '"><br />' + $feature.VictDescrip + '<br /> </span>';
html += TextFormatting.NewLine + '<br />';

if (!IsEmpty($feature.Embeds)) {
    html += TextFormatting.NewLine + '<span><a href="' + $feature.Embeds + '" target="_blank">Visit the Victory' + "'s Media Page</a></span>";
    html += TextFormatting.NewLine + '<br />';
} 

if (!IsEmpty($feature.Link1)) {
    html += TextFormatting.NewLine + '<span><a href="' + $feature.Link1 + '" target="_blank">Learn More About the Victory</a></span>';
    html += TextFormatting.NewLine + '<br />';
}

html += TextFormatting.NewLine + '<a href="' + $feature.Link2 + '" target="_blank">Go to Waterkeeper Website</a>';

return {'type': "text", 'text': html};
RaenaDeMaris
Occasional Contributor

@XanderBakker this is amazing! Thank you so much for taking the time to show me this. I've learned so much!

rbd
0 Kudos
jcarlson
MVP Esteemed Contributor

Very nice! I'm primarily in Portal, so I must've missed when this got added. Thanks for pointing it out!

- Josh Carlson
Kendall County GIS
0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @jcarlson ,

When it comes to changes in the web map I think Enterprise is a bit behind ArcGIS Online. It should come to Enterprise soon and can't wait to see some cool stuff with that. Keep up the good work!

0 Kudos
jcarlson
MVP Esteemed Contributor

Yeah, it usually is. That's part of why I like engaging with questions on here, so that by the time these things land in my Portal toolbox, I've already got a bunch of ideas how to use them.

- Josh Carlson
Kendall County GIS
0 Kudos
RhettZufelt
MVP Notable Contributor

Raena,

Not sure if this pertains, but I have seen some people having issues that "used" to work, but don't now and resolved the issue by using $feature["fieldname"] instead of $feature.fieldname, though, I don't see any spaces in your field names, so "probably" won't make a difference.

 

Also, unless you are using grouped layers or something that will break in Classic Viewer, one option is to turn off popups in Beta viewer, and open in Classic and add the popup config that worked.


R_

0 Kudos
RaenaDeMaris
Occasional Contributor

Hi Rhett, Yes, at first I tried the latter. But I think I'm forced into using New MV popup because it provides a little more flexibility in the ordering of the popup. It's now: attribute related--media related--then attribute related again. In Classic, the attribute followed by media, or media followed by attribute works fine. I'm also using some snazzy dropshadow and bloom symbology in New MV, and it's something I should learn anyway. Thanks for the workaround ideas, though!

rbd
0 Kudos