Pikbase Docs
Open console (opens the console)
Esc

Type to search.

Build

addProperty() — Schema Manager

Add a column to an existing data table.

Contract source@gsb-core/mcp-docs:getDefDocs("addProperty")

Adds a new property (column) to an existing entity definition.

Request Format

addProperty(
    entityDefId: string,     // ID of the entity definition to modify
    property: GsbProperty,   // Property definition to add
    token: string,           // Authentication token
    tenantCode?: string      // Optional tenant code
): Promise<{
    success: boolean,
    data?: boolean,          // Success status
    error?: string
}>

GsbProperty Structure

interface GsbProperty {
  id?: string;                     // Unique identifier (auto-generated if not provided)
  name?: string;                   // Property name (must be unique within entity)
  title?: string;                  // Display title
  description?: string;            // Description
  definition_id?: string;          // Reference to property definition (data type)
  orderNumber?: number;            // Display order
  isRequired?: boolean;            // Whether property is required
  isSearchable?: boolean;          // Whether property is searchable
  isUnique?: boolean;              // Whether property must have unique values
  isPrimaryKey?: boolean;          // Whether property is a primary key
  isIndexed?: boolean;             // Whether property is indexed
  maxLength?: number;              // Maximum length (for strings)
  defaultValue?: string;           // Default value
  
  // Reference properties
  refEntDef_id?: string;           // Referenced entity definition ID
  refEntPropName?: string;         // Property name in referenced entity
  refType?: RefType;               // Reference type (OneToOne, OneToMany, etc.)
  
  // UI control properties
  formModes?: number;              // Form modes where property is visible
  listScreens?: number;            // List screens where property is visible
  
  // Additional properties
  enum_id?: string;                // Enum ID (for enum properties)
  isMultiLingual?: boolean;        // Whether property supports multiple languages
  isEncrypted?: boolean;           // Whether property value is encrypted
  regex?: string;                  // Validation regex pattern
}

Reference Types

When creating reference properties, use one of these reference types:

enum RefType {
  OneToOne = 1,
  OneToMany = 2,
  ManyToOne = 3,
  ManyToMany = 4
}

Response Format

{
    "success": boolean,
    "data": boolean,        // True if property was added successfully
    "error": "string"      // Present only if success is false
}

Example: Adding a Simple Property

const property = {
  name: "address",
  title: "Address",
  description: "Customer address",
  definition_id: "c6c34bf3-f51b-4e69-a689-b09847be74b9", // String type
  isSearchable: true,
  orderNumber: 30
};

const result = await addProperty("entity-id", property, "your-auth-token");

Example: Adding a Reference Property

const property = {
  name: "category",
  title: "Category",
  description: "Product category",
  definition_id: "924acba8-58c5-4881-940d-472ec01eba5f", // Reference type
  refEntDef_id: "category-entity-id",
  refEntPropName: "products", // Creates a 'products' property in Category entity
  refType: 3, // ManyToOne
  orderNumber: 40
};

const result = await addProperty("product-entity-id", property, "your-auth-token");

Auto-Mirror Properties

When adding a reference property with refEntPropName specified:

  1. GSB automatically creates the mirror property in the referenced entity
  2. The relationship is managed bidirectionally
  3. For ManyToMany relationships, a mapping table is created automatically