Formatter […] failed in the evaluation of … The error was: The attribute does not exist. This formatter cannot be called with nonexistent attributes.

  • 14 November 2023
  • 0 replies

Userlevel 5

This error is the equivalent of a null reference expression in ArcScript, and indicates that a formatter is applied to an attr that has not been defined in the script that you are working with.  


The attr that begins the expression is the value that is undefined, such as foo here: 


[ | add()] 


Or an attr in a named class like the _map item: 


[  | add()] 


There are two ways to address this.  


  1. Initialize your attrs:  


You can initialize this attr in an earlier portion of the connector where your script is being executed. If you are using ArcScript, this would be: 


<arc:set attr="" value="" /> 


Using variables in an XML Map, you can simply set the new value: 


Later, when you resolve the attr, the value returned will be the initialized value (even if set to an empty string) when not otherwise set 


  1. Use the def (default) formatter to use a default value if the attr is undefined 


If you are reading the value of an attr, and you are not sure if it has been initialized, you can use the def formatter to use a value to apply if undefined: 


<arc:set attr="myitem.loopCount" value="[myitem.loopCount | def(0) | add(1)]" /> 


In this example, the first time loopCount is resolved, it is set to 0 if undefined (and 1 is added). 


If no argument is provided to def, an empty string will be used: 


[  | def] 


Resolves to an empty string when foo is undefined here. 

This topic has been closed for comments