Error concatenating multiple fields with one arcade attribute rule

1040
5
10-21-2021 11:05 AM
TravysBaker
New Contributor II

Quick disclaimer: I'm still learning arcade and jumping into code like this right off the bat was probably a poor idea.

I'm attempting to cut down on the waste of having three separate rules and combine them into one. The whole idea here is to get the three apn values and combine them in different formats, two text and one integer. We have attribute assistant code that does the same thing. 

My main issue here is that this code works in the dev playground and validates just fine in the expression builder but wont run in pro, where I get the below error message. Any help with this?

TravysBaker_0-1634839395804.png

//
// fields to concatenate
var apnparts = [$feature.BOOK, $feature.PAGE, $feature.NUMBER2DIG]
// the concantenation
var total = Concatenate(apnparts, "-")
var int = Concatenate(apnparts, "", '#')
var nodash = Concatenate(apnparts,"")

return {
    "result" : {
        "attributes" : {
            "$feature.APN_TOTAL" : total,
            "$feature.APN_INTEGER" : int,
            "$feature.APN_NODASH" : nodash
        }
    }
}

 

0 Kudos
5 Replies
JoshuaBixby
MVP Esteemed Contributor

The error indicates it wants newlines or semicolon, have you tried adding those?

//
// fields to concatenate
var apnparts = [$feature.BOOK, $feature.PAGE, $feature.NUMBER2DIG];
// the concantenation
var total = Concatenate(apnparts, "-");
var int = Concatenate(apnparts, "", '#');
var nodash = Concatenate(apnparts,"");

return {
    "result" : {
        "attributes" : {
            "$feature.APN_TOTAL" : total,
            "$feature.APN_INTEGER" : int,
            "$feature.APN_NODASH" : nodash
        }
    }
}
TravysBaker
New Contributor II

Thats my bad, I assumed from the crazy number for the script line being referenced the error was more involved than that.

Now that ive gone from error to error, I've looked through the arcade dev help and haven't really found a way to convert, like in python, a string to an integer or vice versa. It looks like the Number function should do this but my code still errors on the integer field. I'm assuming that's the issue here?

For context, the assessors offices require an integer version of their APNs.  

TravysBaker_0-1634841147615.png

//
// fields to concatenate
var apnparts = [$feature.BOOK, $feature.PAGE, $feature.NUMBER2DIG];
// the concantenation
var total = Concatenate(apnparts, "-");
var intstr = Concatenate(apnparts, "", '#');
var nodash = Concatenate(apnparts,"");
//
var int = Number('intstr', '000000');
//
return {
    "result" : {
        "attributes" : {
            "$feature.APN_TOTAL" : total,
            "$feature.APN_INTEGER" : int,
            "$feature.APN_NODASH" : nodash
        }
    }
}

 

0 Kudos
JoeBorgione
MVP Emeritus

Take a look at the parcel with the global id mentioned above:  my guess is it has a null value or something else goofy in one of the attributes you are trying to concatenate.

 

That should just about do it....
TravysBaker
New Contributor II

Through my testing its every selected parcel exhibits that error and our parcels are pretty clean too, so no nulls or wonkiness here. When I removed the Integer field from the script that error affects the next field, which is No Dash in this case. 

I can get all this to work separately as different rules but combining them is beyond me at this point on the learning curve. 

0 Kudos
JoeBorgione
MVP Emeritus

Happens to the best of us: you get to a point of diminishing returns despite your best efforts!

That should just about do it....