If Then Arcade expression

1103
3
08-18-2019 04:25 PM
CPoynter
Occasional Contributor III

Hi,

I have two fields 'accom' and 'accom_url'.

I am trying to write an arcade expression that will check my table to see if 'accom' exists. If empty, then my pop-up will be empty.

If 'accom' exists but not 'accom_url' then 'accom' text will be placed in pop-up.

If 'accom' exists and 'accom_url' exist, then my pop-up will 'accom' text with hyperlink enabled.

Regards,

Craig

0 Kudos
3 Replies
LanceCole
MVP Regular Contributor

Craig Poynter

Take a look at the following post https://community.esri.com/thread/237247-arcade-expression-ifthen-statement which outlines using conditional statements with or/and operators in Arcade.  If you post the Arcade code that you have so far, I would be glad to respond with additional guidance.

0 Kudos
CPoynter
Occasional Contributor III

Lance,

I have the following:

Accomoodation

IIf(isEmpty($feature.Accommod_1),"", $feature.Accommod_1)

Accommodation URL

IIF (isEmpty($feature.Accom_URL),"",$feature.Accom_URL)

Working as expected. My problem is having the following occur in the pop-up:

AttributeValuesNo Values
AccommodationYes - DisplayNo - Don't display
Accommodation + Accommodation URLYes for both - Display information and associated URL hyperlinkNo for both - Don't display

If I 'set' the URL in the pop-up code using the expression and there is no URL for the 'Accommodation' information, a URL back to the webmap creates a blank return.

Ideally, my Arcade expression and custom pop-up code will be able to show according to the above table if possible.

Regards,
Craig

0 Kudos
LanceCole
MVP Regular Contributor

Craig‌,

You can try something like the following.  You will need to adjust the logic, return strings and add any HTML wrapping as needed but gives you an example.  

if (isEmpty($feature.Accom_Accommod_1)) 
{
  return 'Nothing Found'
}
else if (isEmpty($feature.Accom_URL))
{
  return $feature.Accommod_1
}
else
{
  return Concatenate([$feature.Accommod_1, $feature.Accom_URL], ' - ')
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍