Select to view content in your preferred language

Arcade Pop-up Element Not Returning Field Values

666
3
Jump to solution
10-19-2023 12:04 PM
Labels (3)
ArielLow2146
Frequent Contributor

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.

ArielLow2146_0-1697742214249.png

ArielLow2146_1-1697742233351.png

 

var furl = IIf((!IsEmpty($feature.Website) && Left(Lower($feature.Website), 4)=='http'), $feature.Website, Concatenate(['https://', $feature.Website]))
Console('original url ', $feature.Website)
Console('furl ',furl)

var website = IIf(IsEmpty($feature.Website), "", `<br><a href="${furl}"><strong>Website Link</strong></a>`)

var grades = IIf((IsEmpty($feature.Grade_Lowest_NS12) || IsEmpty($feature.Grade_Highest_NS12) || $feature.Grade_Lowest_NS12==-99 || $feature.Grade_Highest_NS12==-99),
                    "", `<br><strong>Grades:</strong> {Grade_Lowest_NS12} - {Grade_Highest_NS12}&nbsp;`)

return {
    type : 'text',
    text : `<p>
    <strong>Type:</strong> {Type}${grades}${website}
</p>
<p>
    <strong>Address:</strong>
    <br>
    {Site_Address_Line1} {Site_Address_Line2}
    <br>
    {Site_City}, {Site_State} {Site_Zipcode}
</p>`
}
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

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}&nbsp;`, `&nbsp;`)
 
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>`
}

View solution in original post

0 Kudos
3 Replies
jcarlson
MVP Esteemed Contributor

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.

- Josh Carlson
Kendall County GIS
0 Kudos
KenBuja
MVP Esteemed Contributor

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}&nbsp;`, `&nbsp;`)
 
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>`
}
0 Kudos
ArielLow2146
Frequent Contributor

Thank you!!

0 Kudos