# Class ObjectTypeDefinition

- [TopLevel.Object](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md)
  - [dw.object.ObjectTypeDefinition](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md)

The class provides access to the meta data of a system object or custom
object.  A short example should suffice to demonstrate how this metadata can
be used in a script:

```
var co : CustomObject = CustomObjectMgr.getCustomObject("sample", "MyCustomObject");

// get the object type definition
var typeDef : ObjectTypeDefinition = co.describe();
// get the custom object attribute definition for name "enumIntValue"
var attrDef : ObjectAttributeDefinition = typeDef.getCustomAttributeDefinition( "enumIntValue" );
// get the collection of object attribute value definitions
var valueDefs : Collection = attrDef.getValues();

// return function if there are no object attribute value definitions
if(valueDefs.isEmpty())
{
    return;
}

var displayValue : String;
// loop over object attribute value definitions collection
for each ( var valueDef : ObjectAttributeValueDefinition in valueDefs )
{
    if( valueDef.getValue() == co.custom.intValue )
    {
        displayValue = valueDef.getDisplayValue();
        break;
    }
}
```

## Property Summary

| Property                                                                                                                                               | Description                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
| [ID](#id): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`                                            | Returns the type id of the business objects.                                          |
| [attributeDefinitions](#attributedefinitions): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(read-only)` | Returns a collection of all declared attributes for the object.                       |
| [attributeGroups](#attributegroups): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(read-only)`           | Returns a collection of all declared attribute groups.                                |
| [displayName](#displayname): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`                          | Returns the display name of the definition, which can be used in the  user interface. |
| [system](#system): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`                                  | Identifies if this object definition is for a system type or a custom  type.          |

## Constructor Summary

This class does not have a constructor, so you cannot create it directly.

## Method Summary

| Method                                                                                                                                                                                                                                         | Description                                                                           |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| [getAttributeDefinitions](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getattributedefinitions)()                                                                                                   | Returns a collection of all declared attributes for the object.                       |
| [getAttributeGroup](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getattributegroupstring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md))                       | Returns the attribute group with the given name within this object  type definition.  |
| [getAttributeGroups](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getattributegroups)()                                                                                                             | Returns a collection of all declared attribute groups.                                |
| [getCustomAttributeDefinition](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getcustomattributedefinitionstring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)) | Returns the custom attribute definition with the given name.                          |
| [getDisplayName](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getdisplayname)()                                                                                                                     | Returns the display name of the definition, which can be used in the  user interface. |
| [getID](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getid)()                                                                                                                                       | Returns the type id of the business objects.                                          |
| [getSystemAttributeDefinition](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#getsystemattributedefinitionstring)([String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)) | Returns the system attribute definition with the given name.                          |
| [isSystem](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectTypeDefinition.md#issystem)()                                                                                                                                 | Identifies if this object definition is for a system type or a custom  type.          |

### Methods inherited from class Object

[assign](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#assignobject-object), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject), [create](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#createobject-object), [defineProperties](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertiesobject-object), [defineProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#definepropertyobject-object-object), [entries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#entriesobject), [freeze](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#freezeobject), [fromEntries](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#fromentriesiterable), [getOwnPropertyDescriptor](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertydescriptorobject-object), [getOwnPropertyNames](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertynamesobject), [getOwnPropertySymbols](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getownpropertysymbolsobject), [getPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#getprototypeofobject), [hasOwnProperty](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#hasownpropertystring), [is](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isobject-object), [isExtensible](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isextensibleobject), [isFrozen](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isfrozenobject), [isPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#isprototypeofobject), [isSealed](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#issealedobject), [keys](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#keysobject), [preventExtensions](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#preventextensionsobject), [propertyIsEnumerable](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#propertyisenumerablestring), [seal](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#sealobject), [setPrototypeOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#setprototypeofobject-object), [toLocaleString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tolocalestring), [toString](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#tostring), [valueOf](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valueof), [values](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Object.md#valuesobject)

## Property Details

### ID

- ID: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the type id of the business objects.

***

### attributeDefinitions

- attributeDefinitions: [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(read-only)`
  - : Returns a collection of all declared attributes for the object.
    The collection contains both system and custom attributes. There might
    be system and custom attribute with identical names. So the name of the
    attribute is not a uniqueness criteria. Additional the isCustom() flag
    must be checked.

***

### attributeGroups

- attributeGroups: [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md) `(read-only)`
  - : Returns a collection of all declared attribute groups. A attribute group
    is a collection of attribute, which are typically displayed together as
    a visual group.

***

### displayName

- displayName: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md) `(read-only)`
  - : Returns the display name of the definition, which can be used in the
    user interface.

***

### system

- system: [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md) `(read-only)`
  - : Identifies if this object definition is for a system type or a custom
    type.

***

## Method Details

### getAttributeDefinitions()

- getAttributeDefinitions(): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md)
  - : Returns a collection of all declared attributes for the object.
    The collection contains both system and custom attributes. There might
    be system and custom attribute with identical names. So the name of the
    attribute is not a uniqueness criteria. Additional the isCustom() flag
    must be checked.

    **Returns:**

    - a collection of all declared attributes for the object.

***

### getAttributeGroup(String)

- getAttributeGroup(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [ObjectAttributeGroup](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectAttributeGroup.md)
  - : Returns the attribute group with the given name within this object
    type definition.

    **Parameters:**

    - name - The name of the attribute scope to return.

    **Returns:**

    - The matching attribute scope or `null` if no such
      scope exists.

***

### getAttributeGroups()

- getAttributeGroups(): [Collection](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.util.Collection.md)
  - : Returns a collection of all declared attribute groups. A attribute group
    is a collection of attribute, which are typically displayed together as
    a visual group.

    **Returns:**

    - a collection of all declared attribute groups.

***

### getCustomAttributeDefinition(String)

- getCustomAttributeDefinition(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [ObjectAttributeDefinition](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectAttributeDefinition.md)
  - : Returns the custom attribute definition with the given name. The method
    returns null if no custom attribute is defined with that name.

    **Parameters:**

    - name - The unique name of the custom attribute definition within the  object type.

    **Returns:**

    - The matching attribute definition or `null` in
      case no such definition exists.

***

### getDisplayName()

- getDisplayName(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the display name of the definition, which can be used in the
    user interface.

    **Returns:**

    - the display name of the definition, which can be used in the
      user interface.

***

### getID()

- getID(): [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)
  - : Returns the type id of the business objects.

    **Returns:**

    - the type id of the business objects.

***

### getSystemAttributeDefinition(String)

- getSystemAttributeDefinition(name: [String](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.String.md)): [ObjectAttributeDefinition](/docs/commerce/b2c-commerce/references/b2c-script-api/dw.object.ObjectAttributeDefinition.md)
  - : Returns the system attribute definition with the given name. The method
    returns null if no system attribute is defined with that name. Only
    system objects have system attributes. A CustomObject has no system attributes
    and so the method will always return null for a CustomObject.

    **Parameters:**

    - name - The unique name of the custom attribute definition within the  object type.

    **Returns:**

    - The matching attribute definition or `null` in
      case no such definition exists.

***

### isSystem()

- isSystem(): [Boolean](/docs/commerce/b2c-commerce/references/b2c-script-api/TopLevel.Boolean.md)
  - : Identifies if this object definition is for a system type or a custom
    type.

    **Returns:**

    - true if this object definition is for a system type, false otherwise.

***
