You can use your custom data type to:
- Constrain the values that users are allowed to assign to properties of this data type. For example, you could create an Exchange data type that only allows a user to enter recognised market identifier codes for a particular transaction property.
- Store additional reference data against the set of allowed values for properties of this data type. For example, you could create a NaceCode data type that simultaneously constrains the user to only entering recognised NACE codes, and additionally stores the full activity definition for each code (see the example below). This means you don't have to create additional properties to store this information.
Note: If you are the LUSID domain owner, you are automatically assigned the built-in lusid-administrator role, which has all the permissions necessary to perform the operations in this article.
To create a custom data type:
- Obtain an API access token.
- Call the LUSID CreateDataType API, passing in your API access token and a suitable definition for the data type. For example, the following snippet creates a data type that constrains, describes and extends the first five NACE codes:
Note the following about NaceCode:
- Specifying a typeValueRange of Closed constrains the user to only entering allowed values (see below) for properties of this data type. The opposite value (Open) allows the user to enter any value.
- Since valueType is a String, unitSchema and acceptableUnits are not required.
- Since typeValueRange is Closed and we're defining referenceData, acceptableValues are not required (the reference data becomes the allowed values).
- The fieldDefinitions define the quality and quantity of reference data fields.
- For each item of reference data in values:
- value defines the allowed value the user is able to enter for properties of this data type.
- fields define the actual reference data to store against the value, where each field value is mandatory and/or unique according to its fieldDefinition.