Skip to main content

Bulk Add Fields

Create multiple new Fields in a specified Table.

bulk_add_fields(
tableId: ID,
memberId: ID,
fields: AppStructureField[],
reportIds?: ID[]
): Promise<void>;
Parameter NameTypeDescription
tableIdstringThe Id of the Table to create the fields in.
memberIdstringMember Id of the creating Member.
fieldsAppStructureField[]Member Id of the creating Member.
reportIdsstring[]Array of View (report) Ids to add the new fields to.

AppStructureField

Object used to define the new fields to be added in bulk.

export interface AppStructureField<TParams = AppStructureFieldParams> {
slug: string;
label: string;
field_type: Fields;
params: TParams;
id?: ID;
is_new?: boolean;
}
Property NameTypeDescription
slugstringThe slug (unique Id) of the field.
labelstringThe field display name.
field_typestringThe SmartSuite field type.
paramsfield params objectThe field's configuration parameters.
id?stringField Id (should be null or omitted for create).
is_new?booleanA true value indicates that the field is new.

AppStructureFieldParams

export interface AppStructureFieldParams {
required?: boolean;
unique?: boolean;
hidden?: boolean;
help_text?: string;
help_doc?: any;
placeholder?: string;
default_value?: TValue;
width?: 0 | 1 | 2 | null;
}
Property NameTypeDescription
required?booleantrue if field is required.
unique?booleantrue if field value must be unique.
hidden?booleantrue if field is hidden in the UI.
help_text?stringField help text.
placeholder?stringField placeholder text.
default_value?stringField default text.
width?numberField column width in edit record mode.
Example Script - Bulk Add Fields

<!-- bulk_add_fields(
appId: ID,
memberId: ID,
fields: AppStructureField[],
reportIds?: ID[]
): Promise<void>;-->

<script>

window.SmartSuite.bulk_add_fields('675adf9bb73844be508989b8', '6613e6ec7241809b1756db91', [
{
'label': 'Text 3',
'field_type': 'textfield',
'params': {
'primary': false,
'restore_application_id': null,
'linked_field_slug': null,
'max_length': null,
'composite': null,
'delimiter': ', ',
'required': false,
'unique': false,
'hidden': false,
'help_text': '',
'help_text_display_format': 'tooltip',
'placeholder': 'Write here',
'default_value': null,
'width': 1,
'system': false,
'valid': true,
'is_migrating': false,
},
'is_new': true,
}
]).then((res) => {
console.log('result =>>>', res);
});

</script>