Arcade Editor/Map Spec: Add Map Level User-Defined Functions

806
2
06-04-2022 02:55 PM
JustinReynolds
Occasional Contributor III

Add the ability to create User-Defined functions at the map level that can be called by any expression like Arcade's built-in functions. This will dramatically cleanup a lot of reused code from one field or layer to the next. Write it once, call it when it is needed.

What might be needed to make this happen.

  • A place in Field Maps to author these functions.  
  • A new section in the maps definition (JSON)... e.g. userDefinedFunctionInfos[]
  • Define function properties:
    • function name
    • function expression
    • function description (shown in the blue information symbol, so a user knows what the function does and what parameters it takes)
  • A new tab in the Arcade Editor "User-Defined Functions".
  • Validating that the name of the function does not conflict with the name of a built-in function or prefixing the name of the function with text that ensures it can never conflict with a built in function.
2 Comments
JCGuarneri

This would be really useful to us. We have a bit of code that gets hyperlinks for as-builts from intersecting areas. Right now, we need to apply this code individually to each layer where we want to see those links. If I need to make a change, I need to change that in every layer to make sure things work properly.

JohnFannon

Completely agree with this. It's not best coding practice to have multiple copies of the same code and creates a maintenance nightmare.

If we could create re-useable functions, like you can in pretty much any other coding/scripting language, and re-use those within the same map, that would be very useful and also help create more robust applications for customers/end users.