All,
I have been stumped with getting an Arcade expression working! In the end, I would like to have an expression that has a Primary Contact (with address information) and, if present, Secondary Contact (with address information). I have the two working separately, but if there is not a Secondary Contact, it returns a blank line. If there isn't a Secondary Contact I'd like it to just be skipped so there isn't an extra line in the pop-up.
Below is my expression. Lines 1-8 are for the Primary Contact, lines 9-16 are the Secondary Contact, and line 17 is where my problem lies. If the expression returns false, it appears correctly. If the expression returns true, however, nothing is written. I've tried too many different things to list here--help is much appreciated!
var step1Phone = $feature.prim_phone
var step2Phone = FeatureSetByPortalItem(Portal('Removed for Privacy'), 'Removed for Privacy',
0, ['contact_name', 'contact_address1', 'contact_address2', 'contact_city', 'contact_state',
'contact_zip', 'contact_phone', 'contact_email'], false )
var step3Phone = First(Filter(step2Phone, 'contact_phone=@step1Phone'))
var step4Phone = Concatenate("Primary Contact Name:" + TextFormatting.NewLine + step3Phone.contact_name + " (" + Proper($feature.prim_contact_type) + ")" + TextFormatting.NewLine +
step3Phone.contact_address1 + (IIf(IsEmpty(step3Phone.contact_address2), '', TextFormatting.NewLine + step3Phone.contact_address2)) + TextFormatting.NewLine + step3Phone.contact_city +
", " + step3Phone.contact_state + " " + step3Phone.contact_zip + TextFormatting.NewLine + step3Phone.contact_phone + TextFormatting.NewLine + step3Phone.contact_email)
var step5Phone = $feature.sec_phone
var step6Phone = FeatureSetByPortalItem(Portal('Removed for Privacy'), 'Removed for Privacy',
0, ['contact_name', 'contact_address1', 'contact_address2', 'contact_city', 'contact_state',
'contact_zip', 'contact_phone', 'contact_email'], false )
var step7Phone = First(Filter(step6Phone, 'contact_phone=@step5Phone'))
var step8Phone = Concatenate("Secondary Contact Name:" + TextFormatting.NewLine + step7Phone.contact_name + " (" + Proper($feature.sec_contact_type) + ")" + TextFormatting.NewLine +
step7Phone.contact_address1 + (IIf(IsEmpty(step7Phone.contact_address2), '', TextFormatting.NewLine + step7Phone.contact_address2)) + TextFormatting.NewLine + step7Phone.contact_city +
", " + step7Phone.contact_state + " " + step7Phone.contact_zip + TextFormatting.NewLine + step7Phone.contact_phone + TextFormatting.NewLine + step7Phone.contact_email)
return IIf(IsEmpty(step7Phone), step4Phone, step4Phone + TextFormatting.NewLine + TextFormatting.NewLine + step8Phone)