Skip To Content

esri_fielddef_add (AutoLISP)

Adds a new field definition to an existing document feature layer.

Note:

You cannot modify field definitions of a web feature layer.

Syntax

(esri_fielddef_add flname field_properties)

Arguments

  • flname | string | required | An existing document feature layer name in the drawing.
  • field_properties | associated list | required | A list of parameters as dotted pairs as defined in the following table:

Associated labelValue typeValue descriptionRequired or optional
"NAME"

string

Field name.

required

"TYPE"

string

Field type value. {"Double", "Short", "GUID", "Integer", "String", "Float", "Date"}

optional (default "String")

"LENGTH"

integer

Length of the field.

optional

"VALUE"

variant

Default value of field.

Note:

When working with fields that have coded domain values, this is the description, not the code.

optional

Example usage

Attempt to add short integer field called YearPurchased to the Parks feature layer.

(esri_fielddef_add "Parks"
  (list
    (cons "name" "YearPurchased")
    (cons "Type" "Short")
    (cons "value" "1954")
  )
)

Result example usage

A short integer field called YearPurchased is added to the Parks feature layer and a list containing the name of the field is returned.

("YearPurchased")

Return values

  • If successful a list with the field name as a string is returned.
  • If failed, returns a list with the first value of nil and then an associated list containing the key value "Error" and an associated error message as a string: (nil ( "Error" . "<message>"))

Failed return values

A failed return value can occur for any of the following reasons:

  • (nil ("Error" . "Missing required argument."))

    One or more of the required arguments is not supplied.

  • (nil ("Error" . "Field name already exists."))

    The field name used already exists.

  • (nil ("Error" . "Feature layer not found."))

    The specified feature layer value is not a valid feature layer in the drawing.

  • (nil ("Error" . " Schema doesn't support editing."))

    You cannot modify field definitions of a web feature layer.