Create Fields
When you call the createField method to create a field, you must specify the following required parameters.
Parameter
Description
object
Full identifier of the object to which the field is related. Cannot be used to create fields that are not related to an existing object.
name
Field name.
identifier
Unique field identifier.
namespace
Identifier of the namespace to which the created field belongs.
application
Name of the application to which the created field belongs.
datatype
Identifier of the data type for the created field.
You can specify additional attributes with the optional additionalFields parameter. This parameter is a Map whose key corresponds to any valid full field identifier for the Field object. For example, you can specify io_short_description, io_update_safe, io_indexed, or similar identifiers in an additionalFields map. For non-required fields that are not specified in this parameter, default values are set.
The following fields are automatically set and cannot be overridden:
io_uuid: Automatically generated.
io_deleted: Automatically set to false.
io_seed_field: Automatically set to false.
Signature fields (created_on, created_by, and so on).
io_owner: Automatically set to the authenticated user.
When you create fields, the Max platform automatically creates field options that correspond to the specified data type.
createField() Method Definition
Creates and returns a field. If invalid parameters are specified, or if the field cannot be created on the platform (for example, because it is invalid), an exception is thrown.
public static IMaxObject createField(String relatedObjectFullIdentifier, String name, String identifier, String namespaceIdentifier, String applicationName, String datatypeIdentifier, Map<String,Object> additionalFields = [:])
* 
You can use this method to create fields of any data type except Relationship, Dynamic Relationship, and Option List. For more information, see Create Relationship and Dynamic Relationship Fields and Create Option List Fields.
Example
To create a Boolean field named Test Field with the test_field identifier for the Showcase object, in the io namespace and Max application:
import com.servicemax.core.utils.Definitions
Definitions.createField('io_showcase', 'Test Field', 'test_field', 'io', 'Max', 'boolean')
For more information:
Was this helpful?