Hello! I am trying to filter a featureset to only show features that contain carriage returns within a list element.
Here is what I have so far, which currently works in test BUT does not allow me to select within data expressions:
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 null
}
The error that I am getting is 'Unable to execute Arcade Script". What am I doing wrong? Is it possible to accomplish this?
Solved! Go to Solution.
For a Data Expression, you need to return a FeatureSet, no matter what. It's fine to return the result of the Filter function, even if there are no matching features. Also, the Filter expression takes a SQL statement, not an Arcade variable. Try something like this:
var portal = Portal('portal url')
var fs = FeatureSetByPortalItem(portal, "itemid", 0, ['STREETNAME'],false)
return Filter(fs, "STREETNAME LIKE '%\r%'")
That should filter to the features where the field has a return somewhere in them. Not sure how your database will like that, though. You may need to use a function to specify the carriage return character.
'%'+char(13)+'%' or name like '%'+char(10)+'%'
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 null
}
For a Data Expression, you need to return a FeatureSet, no matter what. It's fine to return the result of the Filter function, even if there are no matching features. Also, the Filter expression takes a SQL statement, not an Arcade variable. Try something like this:
var portal = Portal('portal url')
var fs = FeatureSetByPortalItem(portal, "itemid", 0, ['STREETNAME'],false)
return Filter(fs, "STREETNAME LIKE '%\r%'")
That should filter to the features where the field has a return somewhere in them. Not sure how your database will like that, though. You may need to use a function to specify the carriage return character.
'%'+char(13)+'%' or name like '%'+char(10)+'%'