Select to view content in your preferred language

Using arcade to filter list in dashboard

157
2
a month ago
Labels (1)
sophered
New Contributor III

Hello! I am trying to use an arcade expression to isolate features that contain carriage returns for a certain field within a list on my dashboard.  Possibly using '\r.' As of right now, I've tried a few things like the Find function, but no luck yet. I would love some help on this! Once again, I would like to highlight features that have carriage returns in their NAME field, not filter them out. 

0 Kudos
2 Replies
RickeyFight
MVP Regular Contributor

@sophered 

Try this Arcade expression that highlights features with carriage returns in the NAME field:

 

var nameField = $feature.NAME;
var carriageReturnPosition = Find("\r", nameField);

// Check if a carriage return character is found in the NAME field
if (carriageReturnPosition != -1) {
    // Return a custom message or value to indicate the presence of a carriage return
    return "Contains Carriage Return";
} else {
    // Return a different message or value to indicate no carriage return
    return "No Carriage Return";
}

 

 

sophered
New Contributor III

Hello, I adjusted accordingly to be applicable to my data. 

var portal = Portal('portal url')
var fs = FeatureSetByPortalItem(portal, "itemid", 0, ['STREETNAME'],false)
var carriageReturnPosition = Find("\r", fs);
if (carriageReturnPosition != -1) {
return Filter(fs, carriageReturnPosition)
} else {
return "No Carriage Returns in Street Names"
}

I am doing this in a data expression for the list element. However, when I run the test, it is fine BUT when i try to select the expression, it says that it is unable to execute the arcade expression. What am I doing wrong, how do i make these display within the list element  

0 Kudos