Select to view content in your preferred language

Filter Error from Arcade Expression --No Error in Probut in Portal there is?

707
2
Jump to solution
05-05-2023 06:14 AM
RVx_GaslineGiS
New Contributor III

I have an arcade expression that pulls data from a relationship into the associated feature class's popup. It loops through multiple associated records and outputs all found ones for that feature class. In Pro, it outputs correctly to the popup.

 

However, in Portal,I get an error: Execution Error:Filter cannot accept this parameter type.

I'm not quite sure how to fix this. Any advice?

 

// access multiple fields in related table
var tbl = FeatureSetByRelationshipName($feature,"UNDATA.PipelineLine_ServiceHistory");

//connecting feature
var mxloc = $feature["MXLOCATION"];
//sql expression for related tbl
var tbl_sql = "MXLOCATION = @mxloc"
var histories = Filter(tbl, tbl_sql)
var cnt = Count(histories)
//Console(cnt)
var result = "";

//Loop through each record
if (cnt > 0) {
    result = cnt + " Record(s):" + TextFormatting.NewLine;
    // for each record, get information and append to result output
    for (var history in histories) {
        var txt_mxloc = Text("Asset Number: " + history.ASSETNUM) + TextFormatting.NewLine;
        var txt_date = txt_mxloc + "- Install Date: " + Left(Text(history.INSTALLDATE), 9) + TextFormatting.NewLine;
        //var txt_dsc = txt_date + "- Description: " + Text(history.DESCRIPTION);
        var txt_dsc = txt_date + "-Description: " + Text(Round(history.PIPELEN)) + " ft " + Text(history.DIAMTR_C) + '" ' + Text(history.PIPEMATL) + TextFormatting.NewLine;
        var txt_coat = txt_dsc + "-Coating: " + Text(history.COATTYPE);
        result += TextFormatting.NewLine + txt_coat;
    }
}
else {
    result = "No Records";
}
Console(result)
return result

 

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
RVx_GaslineGiS
New Contributor III

The result ended up being that the relationship name as it was in Pro changes when published into Portal so the expression had to be modified to reflect that within Portal side.

View solution in original post

0 Kudos
2 Replies
jcarlson
MVP Esteemed Contributor

For filter statements, I actually prefer using template literals. Try this instead:

var tbl_sql = `MXLOCATION = '${$feature['MXLOCATION']}'`

I'm assuming that field is a string? Remove the single quotes if not.

I would also suggest using template literals and Concatenate to build your output string. Template literals will actually respect line breaks! Makes it a bit easier to manage a long string like you're working with. So you can do this in your loop:

//Loop through each record
if (cnt > 0) {
    var record_arr = []
    Push(record_arr, `${cnt} Record(s):\n`)

    for (var history in histories) {
        Push(
            record_arr,
            `Asset Number: ${history.ASSETNUM}
- Install Date: ${Left(Text(history.INSTALLDATE), 9)}
- Description: ${history.DESCRIPTION}
-Description: ${Text(Round(history.PIPELEN))} ft ${Text(history.DIAMTR_C)} ${Text(history.PIPEMATL)}
-Coating: ${Text(history.COATTYPE)}
        )
    }

    // return newline-delimited string from array
    var result = Concatenate(record_arr, '\n')
}
else {
    result = "No Records";
}

 

- Josh Carlson
Kendall County GIS
RVx_GaslineGiS
New Contributor III

The result ended up being that the relationship name as it was in Pro changes when published into Portal so the expression had to be modified to reflect that within Portal side.

0 Kudos