Arcade expression returns nothing

283
6
03-20-2021 10:26 PM
Labels (1)
RabinSubedi
New Contributor III

Hello Esri Community,

I am using an array in arcade to add one additional column to attribute table in arcgis online. While testing this arcade expression, it gives correct result. However when I apply it to all features, it returns nothing in the target field. Can anyone help me with this?

Thanks!

var names = ["Null","JOHNSTOWN","SULLIVANT","MAIZE","RAMP","ULRY","CHERRY BOTTOM","OLDE WORTHINGTON","5TH","HENDERSON","FAIRWAY","KENNY","AIRPORT","STELZER","STELZER","EMERALD","SNOUFFER","OVERBROOK","OVERBROOK","ORION","LIVINGSTON","17TH","17TH","MORSE","COOPER","HALL","LAZELLE","TAYLOR STATION","OLENTANGY RIVER","REFUGEE","REFUGEE","SUMMIT VIEW","SUNBURY","DUBLIN","5TH","TUSSING","DUBLIN","BRIGGS","MOUND","BRICE","WHITTIER","SMOKY ROW","RICH","WESTWOODS","NEIL","NEIL","NEIL","DEMOREST","FRONT","PARSONS","STELZER","ALKIRE","DEMOREST","HENDERSON","AVERY","KING","POLARIS","SULLIVANT","HAMILTON","LIVINGSTON","VINE","CHAMPION","PARSONS","MARION","BRICE","HAMILTON","PARSONS","LOCKBOURNE","LOCKBOURNE","GROVE CITY","BRENTNELL","GALLOWAY","CHERRY BOTTOM","PARSONS","PARSONS","LINWORTH","RAMP","RAMP","SINCLAIR","REFUGEE","REFUGEE","GROVEPORT","LINWORTH","CLEVELAND","CLEVELAND","TUTTLE CROSSING","MORSE","RICH","BRICE","OAKLAND PARK","BETHEL","ALKIRE","ALKIRE","HAYDEN RUN","ALKIRE","BIXBY","EMERALD","SILVER SPRINGS","0","EAKIN","STELZER","MORSE CROSSING","SHANNON","TUSSING","GANTZ","HAGUE","ORION","HARDY PARKWAY","SCIOTO CROSSING","TRABUE","EASTON","WINCHESTER","ONGARO","CASSADY","GRANDVIEW","SHOOK","POLARIS","HENDERSON","GEORGESVILLE","SAWMILL","PHILLIPI","MAIZE","MAIZE","FRANTZ","MORSE","MCCUTCHEON","5TH","5TH","LEE","CASSADY","KING","KING","SNOWDEN","PARK","OLENTANGY RIVER","SCHROCK","HILLIARD & ROME","SHANNON","JOHNSTOWN","SNOUFFER","LEGEND","SHANNON","WHITTIER","WHITTIER","MARTIN LUTHER KING JR","ALKIRE","OLDE WORTHINGTON","KARL","LEE","JOYCE","JOYCE","LANE","17TH","17TH","LEONARD","NORTH BROADWAY","FRANTZ","COURTRIGHT","KARL","BIG RUN SOUTH","MCNAUGHTEN","LONG","RAMP","SHANNON","OLENTANGY RIVER","OLENTANGY RIVER","WILLOWAY","KELTON","LEONARD","TRABUE","BRENTNELL","PARK","FAIRWOOD","WORTHINGTON WOODS","TAYLOR","LOCKBOURNE","0","FAIRWOOD","LANE","LANE","WHITTIER","WHITTIER","FISHINGER","SOUDER","MOOBERRY","FRONTAGE RD I-71","GRANDVIEW","REFUGEE","REFUGEE","DUBLIN-GRANVILLE","SAWMILL VILLAGE","5TH","WATKINS","BRADENTON","NOE BIXBY","GRANT","ALTON CEMETERY","TWIN RIVERS","NORTH STAR","FRANK","DUBLIN","HIGH","EBRIGHT","HARD","FERRIS","HALL","HALL","STELZER","STELZER","COOPER","FRANTZ","FRANTZ","HILLIARD & ROME","SPINDLER","CANDLESTICK","LIVINGSTON","LAZELLE","FLINT","PARK PLACE","DUBLIN","WILSON","SOUDER","SNOUFFER","5TH","SHANNON","FRANK","DAVIS","FISHER","NORTH STAR","FISHINGER","AVERY","OBETZ","HAYDEN RUN","LANE","SHANNON","ROSEHILL","RENNER","YEARLING","WILSON","OLENTANGY RIVER","JAMES","TUTTLE XING BLVD TO I-270 S","RAMP","HIGH","5TH","HALL","NATIONWIDE","TOWN","MCKINLEY","MCKINLEY","DUBLIN","BIG RUN SOUTH","HOLT","OBETZ","FRANK","FRANK","CENTRAL COLLEGE","I-270","WOODCREST","ALKIRE","GROVEPORT","I-670","AIRPORT","STYGLER","WATKINS","MOUND","FLINT","SR 315","LONDON GROVEPORT","HARLEM","MAIN","NORTH BROADWAY","HAGUE","GALLOWAY","HARMON","HARMON","HARMON","PARSONS","WATKINS","WILSON","WILSON","MOUND","INNIS","FERRIS","KILTEALY","SULLIVANT","SULLIVANT","SMOKY ROW","RATHMELL","FAIRWOOD","TOWN","LINWORTH","LOCKBOURNE","LOCKBOURNE","REFUGEE","ALUM CREEK","WASHINGTON","0","TAYLOR","BOWEN","EAKIN","OLENTANGY RIVER","HENDERSON","COUNTRY CLUB","SMOKY ROW","ARNOLD","BROADVIEW","RAMP","SULLIVANT","OLENTANGY RIVER","OLENTANGY RIVER","BETHEL","COOPER","NOE BIXBY","DEMOREST","CEMETERY","WORTHINGTON GALENA","FREBIS","NORTON","LOCKBOURNE","MORSE","MORSE","BRIGGS","HENDERSON","HARMON","HENDERSON","GRANT","OAK","LIVINGSTON","18TH","18TH","LANE","HUDSON","EXIT 112B","CLEVELAND","PARSONS","SUNBURY","MOCK","GOODALE","GOODALE","TRABUE","BROWN","LIVINGSTON","BAUSCH","WORTHINGTON","CHERRY BOTTOM","GROVES","MT VERNON","GEORGESVILLE","GEORGESVILLE","WEST CASE","CENTRAL","LONG","BRITTON","SMOKY ROW","PORT","BRENTNELL","BRICEGROVE","HOLT","KINNEAR","RAMP","GLENWOOD","FERRIS","FERRIS","FERRIS","WARNER","SCIOTO POINTE","FISHER","FISHER","2ND","CASSADY","LOCKBOURNE","NORTH BROADWAY","BETHEL","TRUEMAN","17TH","17TH","ROHR","LONG","FISHER","WESTERVILLE","WINCHESTER","TRABUE","WINCHESTER","MORSE","WINCHESTER","KELTON","KELTON","DODRIDGE","OHIO","OHIO","THOMPSON","NELSON","NORTHWEST","GREENSWARD","LINCOLN PARK","KARL","US 33","HIGH","OLENTANGY RIVER","OLENTANGY RIVER","FULTON","5TH","5TH","CEMETERY","ALKIRE","ALKIRE","JAMES","CORR","NELSON","GREENLAWN","GREENLAWN","GREENLAWN","FRONT","ALKIRE","3RD","HIGH","HENDERSON","WILSON BRIDGE","MOUND","GLENWOOD","ULRY","KENNY","KENNY","HIGH","DUBLIN","ALUM CREEK","I-70","COLE","ULRY","HARLEM","JOYCE","BRICE","BENT TREE","GENDER","CLEVELAND","PLANT","SUNBURY","KENNY","FAIRWOOD","FAIRWOOD","KENNY","SHOOK","ALUM CREEK","ALUM CREEK","LEONARD","LEONARD","I-70","PARSONS","REFUGEE","EASTLAND MALL SVC","GRANT","TAYLOR STATION","LIVINGSTON","RAMP","LANCASTER","TOWN","HIGH","SPRUCE","LIVINGSTON","HOPKINS","FAIRWOOD","FAIRWOOD","OAK","GEMINI","REYNOLDSBURG-NEW ALBANY","FAIRWOOD","FAIRWOOD","CIVIC CENTER","LIVINGSTON","REFUGEE","BLUHM","SUMMIT VIEW","CARMACK","OLENTANGY RIVER","CLEVELAND","0","BIG RUN SOUTH","OLENTANGY RIVER","CHATTERTON","LOCKBOURNE","BARTHMAN","KENNY","BRYDEN","INNIS","INNIS","SISTER NANCY GANSE","CEMETERY","FULTON","LEPPERT","ALUM CREEK","0","DUBLIN-GRANVILLE","LOWELL","HAGUE","NEW ALBANY","FRANKLIN","ALKIRE","FEDER","RAMP","I-71","ROBERTS","ROBERTS","FRANK","CLIME","GENDER","HAYDEN RUN","JAMES","CLEVELAND","LEE","GODOWN","RICKENBACKER","EMERALD","ASKINS","5TH","5TH","5TH","MORSE","GROVEPORT","OAKLAND PARK","SNOUFFER","MORSE","MORSE","PARSONS","CLEVELAND","NEIL","HARD","POLARIS","SPRUCE","BROWN","BIG RUN SOUTH","BIG RUN SOUTH","SUNBURY","GODOWN","HILLIARD & ROME","HILLIARD PARK","SCHROCK","FEDER","18TH","HAMILTON","JAMES","CEDAR","JOYCE","HUDSON","SUMMER","FRONT","OLENTANGY RIVER","DODRIDGE","SPRUCE","LIVINGSTON","HAYDEN RUN","MAIN","GRANDVIEW","SULLIVANT","HARTFORD","ULRY","5TH AVE TO STELZER","MOUND","MOUND","NORTH BROADWAY","PARSONS","COLUMBUS CONVENTION CENTER","WILSON","NOE BIXBY","PARSONS","GRANDVIEW","DUBLIN-GRANVILLE","0","MAIN","MAIN","LONG","0","MORSE","KELTON","HAGUE","NORTON","5TH","HIGH","CAMPUS VIEW","JAMES","HUDSON","HUDSON","HUDSON","BRICE","KINNEAR","HICKORY","SUNBURY","VALLEY VIEW","LONG","DYER","CASSADY","BRICE","DEMOREST","KARL","ALKIRE","ACKERMAN","LISLE","SPRING","SPRING","FRANKLIN","LESTER","PHILLIPI","3RD","3RD","TRABUE","WHITTIER","WHITTIER","HIGH","SUMMIT VIEW","LIVINGSTON","MCCUTCHEON","SANCUS","LESTER","TOWN","PARSONS","WINCHESTER","SINCLAIR","GOODALE","ROBERTS","FRANK","HARMON","GROVES","HAGUE","MAIN","SUNBURY","HARD","NORTH BROADWAY","LANE","CASSADY","CASSADY","2ND","2ND","WORTHINGTON","PARSONS","PARSONS","CHATTERTON","OBETZ","CASSADY","LINWORTH","SAWMILL","WILLIAMS","HOLT","JOYCE","CASSADY","CASSADY","11TH","11TH","I-71","HAMILTON","SHANNON","HILLIARD & ROME","HILLIARD & ROME","NORTHWEST","STELZER","RAMP","EASTON","EAKIN","RAVINE","MOUND","SUMMIT VIEW","JOYCE","NORTH BROADWAY","NORTH BROADWAY","NEW ALBANY","CHAMPION","HIGH","CLEVELAND","NOE BIXBY","WOODCREST","LEHMAN","GEORGESVILLE","FISHER","FISHER","MORSE","DAVIS","NEW ALBANY","PARK","GROVES","RICH","DUBLIN","HIGH","HIGH","LONG","CENTRAL COLLEGE","WILLIAMS","MARION","OLD STATE","BRICE","ASCHINGER","WALTON","WEBER","OLENTANGY RIVER","FREBIS","HIGH","I-670","NEIL","MCKINLEY","GENDER","BRICE","BAUSCH","VINE","HARLEM","VALLEY VIEW","TRABUE","TRABUE","JAMES","CONNECTOR","WINCHESTER","KING","MCKINLEY","CHAMPION","WEST CASE","EAKIN","EAKIN","KENNY","GANTZ","HICKORY","STARR","OHIO","OHIO","JAMES","RAMP","LEONARD","RIVERSIDE","WALTON","THOMAS","GRANT","0","MOCK","MOCK","CONNECTOR","BETHEL","TUSSING","CHITTENDEN","GEORGESVILLE","MCKINLEY","HAMILTON","WESTBELT","REFUGEE","BROAD","STYGLER","AGLER","LOCKBOURNE","OBETZ","MT VERNON","SANCUS","EBRIGHT","LINCOLN","LINCOLN","BROWN","GRANDVIEW","OLENTANGY RIVER","CASSADY","RENNER","CENTRAL COLLEGE","WAGGONER","AIRPORT","BRICE","FRONT","FRONT","DEMOREST","BRITTON","CASSADY","WORTHINGTON GALENA","SOUDER","SOUDER","5TH","5TH","SUNBURY","SUNBURY","MORSE","MORSE","THOMPSON","SPRING","3RD","BRICE","SANCUS","BIG RUN SOUTH","REFUGEE","FISHINGER","OLENTANGY RIVER","HAYDEN RUN","SPRUCE","STELZER","SULLIVANT","HARMON","HARMON","THURMAN","CLEVELAND","RAMP","FULTON","DEMOREST","MT VERNON","OHIO","GEMINI","MORSE","MORSE","GEORGIA","NORTON","ALTON","RIVERSIDE","GOODALE","SR 315","5TH","HAYDEN RUN","LEHMAN","MCKINLEY","HARPER","MOUND","5TH","BRICE","MCCUTCHEON","GENDER","CHERRY BOTTOM","VALLEY VIEW","BRIGGS","BRIGGS","HAGUE","WILLIAMS","CHAMPION","CHAMPION","COLE","CHITTENDEN","HUDSON","MCNAUGHTEN","11TH","NELSON","MAIN","OLD DUBLIN","ALUM CREEK","EASTON","LAZELLE","BIG RUN SOUTH","ROBINBROOK","PARK","HARDY PARKWAY","HIGH","SAWMILL","FONTAINE","JOYCE","RICKENBACKER","TRABUE","HENDERSON","SAINT CLAIR","SAINT CLAIR","WESTERVILLE","AGLER","HICKORY","SUNBURY","GOODALE","REFUGEE","EASTLAND MALL SVC","MOOBERRY","17TH","RAMP","COLLEGE","LINWORTH","WINCHESTER","WEBER","ALTON & DARBY CREEK","ALTON & DARBY CREEK","WASHINGTON","RAMP","MORSE","PORT","EMERALD","LIVINGSTON","BYRD","HAYDEN","ROBERTS","MOUND","MCKINLEY","NAGHTEN","EMERALD","WILCOX","BIG RUN SOUTH","WILSON PARK","COSGRAY","WATKINS","COURTRIGHT","WILLIAMS","FRANTZ","HENDERSON","HENDERSON","ROBERTS","STELZER","REFUGEE","JOYCE","JOYCE","NORTH STAR","YEARLING","RAMP","GROVEPORT","MORSE CROSSING","MORSE CROSSING","TUSSING","FREBIS","INTERNATIONAL","HAYDEN RUN","TRABUE","SNOUFFER","HIGH","HUNTLEY","GEORGESVILLE","SPINDLER","HARD","NEIL-GOODALE","LEHMAN","KARL","COOKE","THURMAN","WESTDALE","SANCUS","NAGHTEN","2ND","DEMOREST","WINCHESTER","SHANNON","GOVERNOR","HARDY PARKWAY","HOSACK","ORION","COOKE","OLD STATE","THURMAN","TRABUE","WEST CASE","COURTRIGHT","HOLT","OAKLAND PARK","OAKLAND PARK","5TH","5TH","LAZELLE","HOLT","WAGGONER","SHOOK","MCKINLEY","GRANT","OLD HAMILTON","REFUGEE","NORTH BROADWAY","NORTH BROADWAY","WILCOX","BIG RUN SOUTH","5TH","WILLIAMS","THURMAN","THURMAN","HIGH","LAZELLE","HIGH","HIGH","MCNAUGHTEN","MARCONI","LAZELLE","REFUGEE","LIVINGSTON","WOODCREST","STATE","ALUM CREEK","CLIME","HALL","FRONT","PARSONS","ROBERTS","INNIS","SULLIVANT","GRENER","FRONT","COOKE","MOUND","WEST CASE","LONG","I-270","DEMOREST","0","SUNBURY","SAWMILL","SAWMILL","CHAMPION","5TH","CLEVELAND","KING","BRENTNELL","CASSADY","GALLOWAY","WARNER","5TH","CONNECTOR","SULLIVANT","SMOKY ROW","FULTON","MCGUFFEY","DUBLIN-GRANVILLE","JOYCE","JOYCE","REYNOLDSBURG-NEW ALBANY","CENTRAL","BRICE","HAGUE","11TH","SCIOTO DARBY CREEK","WOODSON","HIGH","BARNES","HILLIARD & ROME","SOUDER","GREENLAWN","LONG","WASHINGTON","COURTRIGHT","SUNBURY","COSGRAY","AGLER","CHERRYBLUFF","SMILEY","CENTRAL COLLEGE","ROBERTS","WINCHESTER","I-670","FRONT","ROBERTS","WILLIAMS","3RD","3RD","ROWE","INDIANOLA","HAYDEN RUN","HAYDEN RUN","COOPER","HARDESTY","OLENTANGY RIVER","FERRIS","FERRIS","CLEVELAND","HARD","KENNY","PHILLIPI","NORTHWEST","HARDY PARKWAY","LEAP","ALTON DARBY CREEK","RIVERSIDE","LIVINGSTON","EMERALD","PARK","HARLEM","CAMERON CROSSING","DUBLIN-GRANVILLE","HOLT","AVERY","RENNER","0","5TH TO HAMILTON","STIMMEL","GODOWN","WORTHINGTON CENTRE","LINWORTH","SUNBURY","BROAD","HIGH","HAMILTON","WINCHESTER","0","3RD","HUDSON","STIMMEL","GANTZ","STELZER","MOUND","MOUND","CENTRAL COLLEGE","WORTHINGTON","5TH","SUNBURY","SUNBURY","WEBER","WEBER","LONDON GROVEPORT","HARPER","REYNOLDSBURG-NEW ALBANY","WASHINGTON","NOE BIXBY","WARNER","HUDSON","HUDSON","HUDSON","HUDSON","NEW ALBANY","NEW ALBANY","REFUGEE","REFUGEE","REFUGEE","REFUGEE","REFUGEE","REFUGEE","ALKIRE","ALKIRE","REFUGEE","REFUGEE","REFUGEE","REFUGEE","3RD","3RD","SOUDER","SOUDER","HARMON","HARMON","MORSE","MORSE","RAMP","RAMP","MORSE","MORSE","I-670","I-670","HARMON","HARMON","I-670","I-670","I-670","I-670","FERRIS","FERRIS","OLENTANGY RIVER","OLENTANGY RIVER","5TH","5TH","I-270","I-270","MORSE CROSSING","MORSE CROSSING","STELZER","STELZER","I-670","I-670","OLENTANGY RIVER","OLENTANGY RIVER","MORSE","MORSE"];

return names[$feature.PvtID]
0 Kudos
6 Replies
DavidPike
MVP Frequent Contributor

What do you want to do exactly? Ensure the PvtID is an integer or coerce it to one.

RabinSubedi
New Contributor III

Hello @DavidPike, thanks for your reply.

I have 1140 polyline features and I need to add their street names as a new field based on their pavement ID (here "PvtID", a unique value for each feature). I prepared an array of names in sequential order of pavement ID and I want to return a name corresponding to id of each pavement. When I test this code in arcade, it gives desired result, but when I click 'ok', it says 'all 1140 features are updated' and returns nothing in target field: 'street_names'.

Also, the PvtID value is an integer.

0 Kudos
DavidPike
MVP Frequent Contributor

If there's no error messages I'm not sure what's going on without seeing the entire process.  Perhaps a table join based on the ID field would be much better in any case.

0 Kudos
RabinSubedi
New Contributor III

As per my understanding, table join creates a new feature layer rather than updating the existing one. Since I have used existing layer in many webmaps and different widgets in web appbuilders, I don't want to do that all over again. Is there any way I can update the existing layer with a new column?

0 Kudos
DavidPike
MVP Frequent Contributor

I can only think of some size limitation in the code block, but that doesn't make a great deal of sense.  Can you trial the expression with a  small number of names in the names list to rule this out?   The field you're writing to is also text/string?

0 Kudos
RabinSubedi
New Contributor III

You are right @DavidPike , Seems like it works only for values less than 1000. I broke the array in two parts and it worked!

Thanks!