Updated on 2025-08-28 GMT+08:00

Adding a Field to an Object Instance

Function

This API is used to add required fields to custom object instances.

URI

POST Huawei Cloud Astro Zero domain name/u-route/baas/metadata/v1.0/Object/{object_id}/Field

Table 1 URI parameter

Parameter

Mandatory

Type

Description

Object_id

Yes

String

Explanation

Object instance ID, which can be queried by calling the API of Querying All Custom Objects (id in the response message).

Constraints

None

Value

None

Default value

None

Request Parameters

Table 2 Request parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Explanation

Name of the new field.

Constraints

The value cannot be changed after being specified.

Value

The value must start with a letter and can contain only letters, digits, and underscores (_). It cannot end with an underscore (_) and can contain a maximum of 63 characters.

Default value

None

label

Yes

String

Explanation

Label of the new field.

Constraints

None

Value

1–80 characters

Default value

None

inlineHelpText

No

String

Explanation

Description of the new field.

Constraints

None

Value

1–255 characters

Default value

None

dataLength

Yes

Int

Explanation

Length of new fields.

Constraints

None

Value

1–64 characters

Default value

None

dataType

Yes

String

Explanation

Type of the new field.

Constraints

The value cannot be changed after being specified.

Value

  • text: You can enter a maximum of 255 characters, including any combination of letters and digits.
  • encryptedtext: You can enter a maximum of 111 characters and store them in encrypted format, including any combination of letters and digits.
  • textarea: You can enter up to 1,048,576 characters in multiple lines.
  • number: You can enter any digit. Leading zeros are removed.
  • percent: You can enter a percentage number, for example, 10, and the percent sign is automatically added to the number.
  • phone: You can enter any phone number, which is automatically displayed in the phone number format.
  • currency: You can enter amounts in other currencies, which will automatically be converted to the correct format. This function is useful when exporting data to Excel or other spreadsheets.
  • date: You can enter a date or select a date from the calendar that is displayed.
  • datetime: You can enter a date and time or select a date from the calendar that is displayed. When you click a date in the calendar that is displayed, the date and current time are shown in this field.
  • email: You can enter an email address. The system validates the email address format. If this field is specified for a contact or a potential customer, you can select an address when you send an email. Note that custom e-mail addresses cannot be used for bulk e-mail.
  • checkbox: You can select a true (checked) or false (unchecked) value.
  • singleselect: You can select a value from a defined list.
  • multiselect: You can select multiple values from a defined list.
  • url: You can enter any valid URL. When you click this field, you will visit the URL in a separate browser window.
  • lookup: You can create a relationship that associates this object to another object.
  • autonumber: The system generates serial numbers in the format that you define. The sequence number increases by one for each newly added record.
  • formula: The system generates a read-only field in the formula expression that you define. If the source field used in any expression is changed, the value of this field will be updated.
  • masterdetail: You can create a type of primary/secondary relationship between one object and another. Ownership of detailed records is determined by the master record. When you delete the master record, all detailed records will be deleted.
  • multilanguage: You can select content in multiple languages from the customized resource table.
  • attachment: You can save the addresses of multiple uploaded files. Images and documents are supported.

Default value

None

description

No

String

Explanation

Description of the new field.

Constraints

None

Value

1–80 characters

Default value

None

defaultValue

No

String

Explanation

Default value of the new field.

Constraints

The format must comply with the rules of the type configured in the field type (dataType).

Value

None

Default value

None

caseSensitive

No

Boolean

Explanation

Whether the value is case sensitive. For example, if ABC and abc are considered equal, the setting is case insensitive. If they are treated as different, the setting is case sensitive.

Constraints

None

Value

  • true: The value is case-sensitive.
  • false: The value is case-insensitive.

Default value

false

isRequired

No

Boolean

Explanation

Whether the field is mandatory.

Constraints

None

Value

  • true: The field is mandatory.
  • false: The field is optional.

Default value

false

isUnique

No

Boolean

Explanation

Whether duplicate data is allowed in a field.

Constraints

None

Value

  • true: The field is unique.
  • false: The field is not unique.

Default value

false

profiles

No

Array

Explanation

Profiles assigned. Field-level security configuration. You can configure whether each profile is visible or editable for each field.

Constraints

None

layouts

No

Array

Explanation

Layout name of the field.

Constraints

None

view

No

Object

Explanation

Each item is a string array. The name is the layout of the field, and the content is the fields contained in the layout.

Constraints

None

isSearchable

No

Boolean

Explanation

Whether the search statement can be used to search for the field.

Constraints

None

Value

  • true: The field can be searched.
  • false: The field cannot be searched.

Default value

false

Response Parameters

Table 3 Response parameters

Parameter

Type

Description

resCode

String

Explanation

Return code.

Value

If the request is successful, 0 is returned. For details about other error codes, see Error Codes.

resMsg

String

Explanation

Message returned.

Value

If the request is successful, "Success" is returned. In other cases, an error message is returned.

result

string

Explanation

If the request is successful, an ID is returned.

Value

None

Example Request

To add a field to an object instance, send the following request:
POST https://Huawei Cloud Astro Zero domain name/u-route/baas/metadata/v1.0/Object/cust000000aKoa6I4E6K/Field
{
    "label":"test",
    "name":"CNAME1__test__CST",
    "inlineHelpText":"dsf",
    "description":"fsdf",
    "dataType":"text",
    "dataLength":255,
    "defaultValue":"vfdsg",
    "caseSensitive":true,
    "isRequired":true,
    "isUnique":true,
    "isSearchable":true,
    "profiles":[
        {
            "profile":"000T0000000000000002",
            "readable":true,
            "editable":true
        },
        {
            "profile":"000T0000000000000003",
            "readable":true,
            "editable":true
        },
        {
            "profile":"000T0000000000000004",
            "readable":true,
            "editable":true
        },
        {
            "profile":"000T0000000000000006",
            "readable":true,
            "editable":true
        },
        {
            "profile":"000T000000Tiq6fUQhjK",
            "readable":true,
            "editable":true
        },
        {
            "profile":"000T000000Tiq6lJCs2y",
            "readable":true,
            "editable":true
        },
        {
            "profile":"000T000000W1a8iTFglU",
            "readable":true,
            "editable":true
        }
    ],
    "layouts":[
        "000D000000aKoa6OJOxk"
    ],
    "view":{
        "000D000000aKoa6OJOxk":{
            "fields":[
                "name",
                "test__df__CST",
                "test__sdadsd__CST",
                "test__sdd__CST"
            ]
        }
    }
}    

Example Response

{
  "resCode":"0",
  "resMsg": "Success",
  "result":"cust000000iY8i3Jvyng"
}

Status Code

See Status Codes.

Error Code

See Error Codes.