I've put the following Arcade in an Arcade pop-up element for this layer. In the configuration view of the popup the type and address fields return properly but when I click out of the configuration view the type and address views stop returning.
Is there a different way I should be specifying these fields? It seems like there should be a better way than defining all the fields I want to use as variables.
Solved! Go to Solution.
Try this script
var furl = IIf((!IsEmpty($feature.Website) && Left(Lower($feature.Website), 4)=='http'), $feature.Website, Concatenate(['https://', $feature.Website]))
var website = IIf(IsEmpty($feature.Website), "", `<br><a href="${furl}"><strong>Website Link</strong></a>`)
var grades;
if(!IsEmpty($feature.Grade_Lowest_NS12) && $feature.Grade_Lowest_NS12 > -99) grades += ` <br><strong>Grades:</strong> ${$feature.Grade_Lowest_NS12}`
iif(!IsEmpty($feature.Grade_Highest_NS12) && $feature.Grade_Highest_NS12 > -99, grades += ` - ${$feature.Grade_Highest_NS12} `, ` `)
return {
type : 'text',
text : `<p>
<strong>Type:</strong> ${$feature.Type} ${grades}${website}
</p>
<p>
<strong>Address:</strong>
<br>
${$feature.Site_Address_Line1} ${$feature.Site_Address_Line2}
<br>
${$feature.Site_City}, ${$feature.Site_State} ${$feature.Site_Zipcode}
</p>`
}
Hard to say, really. If that's the literal text of your popup, though, don't you need those address fields to be $feature.Site_Address_Line1, etc? Putting the attribute name in brackets doesn't usually work unless you're configuring a text item for your popup. Since you're using an Arcade element, you probably need the full attribute notation.
Try this script
var furl = IIf((!IsEmpty($feature.Website) && Left(Lower($feature.Website), 4)=='http'), $feature.Website, Concatenate(['https://', $feature.Website]))
var website = IIf(IsEmpty($feature.Website), "", `<br><a href="${furl}"><strong>Website Link</strong></a>`)
var grades;
if(!IsEmpty($feature.Grade_Lowest_NS12) && $feature.Grade_Lowest_NS12 > -99) grades += ` <br><strong>Grades:</strong> ${$feature.Grade_Lowest_NS12}`
iif(!IsEmpty($feature.Grade_Highest_NS12) && $feature.Grade_Highest_NS12 > -99, grades += ` - ${$feature.Grade_Highest_NS12} `, ` `)
return {
type : 'text',
text : `<p>
<strong>Type:</strong> ${$feature.Type} ${grades}${website}
</p>
<p>
<strong>Address:</strong>
<br>
${$feature.Site_Address_Line1} ${$feature.Site_Address_Line2}
<br>
${$feature.Site_City}, ${$feature.Site_State} ${$feature.Site_Zipcode}
</p>`
}
Thank you!!