Select to view content in your preferred language

Popup arcade expression preventing popup opening on iOS

536
1
06-22-2022 08:02 AM
Andy_CS
Regular Contributor

Hi,

One of my popup expressions is preventing my popups opening in Field Maps running on iOS. The expession executes properly in the web map builder and in Field Maps running on Android.

On iOS the user selects a feature and the Popup opens with a warning sign indicating that an expression is preventing the popup from properly loading.

The expression takes an ID value from the selected feature's attributes and uses it to create a feature set from a table containing contact information. It then iterates through each feature in the set and builds a properly formatted contact string from the attributes (newlines are added, Null values are removed).

so

field name in feature set: Name // Street // Town // County // PostCode

value: JD Bloggs // Some Street // Some Town // NULL // PC24

becomes

'JD Bloggs \n Some Street \n Some Town \n PC24'

I've included the expression below, you'll have to excuse the scripting . As I say it does work on android and in the web map builder (old and new). I have a few other expressions set up on my layer and these do work on iOS. (My portal variables are excluded)

Has anyone else had similar problems?

 

 

var featureID = $feature.treTargetSiteID;


// create feature set from contact table using its portal ID
// return all fields with no geometry (it has none anyway)
var fsContacts = FeatureSetByPortalItem(portal, contactTableID, contactTableSubLayer, ['*'], false);
// build filter statement from feature and feature set ID
var filterStatement = '@featureID = tarTargetSiteID';
// return features from the feature set which match the filter statment (return new feature set)
var fsRelatedContacts = Filter(fsContacts, filterStatement);
// sort related features by the date they were added
var fsRelatedContactsSort = OrderBy(fsRelatedContacts, 'conDateAdded DESC');
// create emtpy array to store tidied contact features
var contactsTidy = [];
var contactPopupString = '';
// test if the feature set contains more than 0 features
if (Count(fsRelatedContactsSort) > 0) {
// if it does
// iterate related contacts
    for (var contact in fsRelatedContactsSort){
        // for each related contact
        // create array of contact attributes
        var contactInfo = [
            Concatenate(['Date added:', Text(contact.conDateAdded,'DD/MM/YY')],' '),
            Concatenate(['Type:', iif(!ISEmpty(contact.ctsType),contact.ctsType,'N/A')],' '),
            Trim(Concatenate([contact.conTitle, contact.conFirstName, contact.conLastName],' ')),
            contact.conPosition,
            contact.conAddress1,
            contact.conAddress2,
            contact.conAddress3,
            contact.conTown,
            contact.conPostcode,
            contact.conEmail,
            contact.conPhoneOne,
            contact.conPhoneTwo
        ];
        // empty array to store non-empty contact attributes
        var contactInfoBuilder = [];
        // empty string to store contact string
        var contactString = '';
        // iterate contact info array
        for (var contactElement in contactInfo) {
            // check to see if element is not null
            if (!IsEmpty(contactInfo[contactElement])) {
                // if it is not null add it to non null array
                contactInfoBuilder[Count(contactInfoBuilder)] = contactInfo[contactElement];
            }
            // if element is null then do nothing
            // the contact info builder array now contains only non null contact attributes
        }
        if (!IsEmpty(contactInfoBuilder)) {
            // concatenate the contact info builder array elements into a single string, separate
            // elements with a newline
            contactString = Concatenate(contactInfoBuilder, TextFormatting.NewLine);
            // add the contact string to the final popup array and move onto the next iterated
            // feature
            contactsTidy[Count(contactsTidy)] = contactString;
        }
    }
// concatenate all contact string elements in the contactsTidy array
// into a single string separate each element with a newline
contactPopupString = (Concatenate(contactsTidy, TextFormatting.NewLine));
} else {
    // if the related feature set was empty then return a placeholder string
    contactPopupString = 'No primary contact information';
}
return contactPopupString;

 

 

Tags (3)
0 Kudos
1 Reply
JustinReynolds
Frequent Contributor

Did you check the logs in field maps mobile app?  It should give a line number and some general info about the error.

I'm having a similar issue, but hard to say if it is the same issue.  For me I get a general execution error for Count(fset).  That would be your line 17.  Works fine in the arcade editor, but doesn't work on either iOS or Android.

- Justin Reynolds, PE
0 Kudos