Schema API
Metadata Types

Metadata Types

The Schema API provides methods to query metadata types: field types, system field types, system entry types, and filter operations. HTTP uses intapp-rest-client.

get_field_types()

Returns all available field types:

from dealcloud_sdk import DealCloud, DealCloudConfig
 
config = DealCloudConfig(
    siteUrl="yoursite.dealcloud.com",
    clientId=12345,
    clientSecret="your-secret",
)
dc = DealCloud.from_config_object(config)
 
field_types = dc.get_field_types()
 
for ft in field_types:
    print(f"{ft['id']}: {ft['name']}")

Output

The API returns whatever your site exposes (typically id / name pairs). Inspect the list at runtime; do not assume IDs match another table in this doc.

⚠️

get_field_types() (schema catalog from /fieldtypes) is not the same numbering as Field.fieldType on row data. For the integer codes used on Field.fieldType (e.g. TEXT, REFERENCE, BINARY), use Constants and field.fieldType from get_fields().

Caching

Field types are immutable and automatically cached:

# First call fetches from API
types1 = dc.get_field_types()
 
# Subsequent calls use cache
types2 = dc.get_field_types()  # No API call

Field type integers on Field.fieldType

When you read Field objects from get_fields(), fieldType uses the SDK’s integer constants (see Constants): e.g. TEXT = 1, CHOICE = 2, NUMBER = 3, REFERENCE = 5, BINARY = 13, IMAGE = 16. Compare with field.fieldType == TEXT (import from dealcloud_sdk) for clarity.

get_system_field_types()

Returns system field types (built-in fields):

system_types = dc.get_system_field_types()
 
for st in system_types:
    print(f"{st['id']}: {st['name']}")

System field type id / name pairs come from the API. Print or inspect get_system_field_types() for your site rather than relying on a static table.

💡

Results are cached on the client for the lifetime of the DealCloud instance.

get_system_entry_types()

Returns system entry types (built-in objects):

entry_types = dc.get_system_entry_types()
 
for et in entry_types:
    print(f"{et['id']}: {et['name']}")

System entry type id / name pairs are returned by the API—inspect get_system_entry_types() for your environment.

get_filter_operations()

Returns available filter operations for query building:

operations = dc.get_filter_operations()
 
for op in operations:
    print(f"{op['name']}: {op.get('description', '')}")
⚠️

Filter operations are not cached because they can change. Each call fetches fresh data.

Filter Operations

NameQuery SyntaxApplicable To
Equals$eqAll types
NotEquals$notAll types
Contains$containsText
StartsWith$startswithText
EndsWith$endswithText
GreaterThan$gtNumber, Date
LessThan$ltNumber, Date
GreaterOrEqual$gteNumber, Date
LessOrEqual$lteNumber, Date
Between$betweenNumber, Date
In$inAll types
NotIn$ninAll types
IsNullCheck for nullAll types
And$andLogical
Or$orLogical

get_field_units()

Returns all available field units (measurement annotations for numeric fields):

units = dc.get_field_units()
 
for unit in units:
    print(f"{unit.id}: {unit.name}")

FieldUnit Properties

PropertyTypeDescription
idintUnique unit ID
namestrUnit display name

Example: Build Unit Lookup

def get_unit_map(dc):
    """Build unit ID → name mapping."""
    units = dc.get_field_units()
    return {u.id: u.name for u in units}
 
unit_map = get_unit_map(dc)
print(unit_map)
# {1: "Percentage", 2: "Multiplier", 3: "Basis Points", ...}

get_timezones()

Returns all timezones available in the DealCloud site:

timezones = dc.get_timezones()
 
for tz in timezones:
    print(f"{tz.id}: {tz.displayName}")

Timezone Properties

PropertyTypeDescription
idstrTimezone identifier (e.g., "America/New_York")
namestrShort name (e.g., "Eastern")
displayNamestrFull display name (e.g., "(UTC-05:00) Eastern Time")

Example: Validate Timezone

def validate_timezone(dc, tz_id: str) -> bool:
    """Check if a timezone ID is valid."""
    timezones = dc.get_timezones()
    return any(tz.id == tz_id for tz in timezones)
 
if validate_timezone(dc, "America/New_York"):
    print("Valid timezone")

Building Dynamic Queries

Use filter operations to validate queries:

def get_valid_operations(dc, field_type: int):
    """Get filter operations valid for a field type."""
    operations = dc.get_filter_operations()
    
    valid = []
    for op in operations:
        applicable_types = op.get('applicableFieldTypes', [])
        if not applicable_types or field_type in applicable_types:
            valid.append(op['name'])
    
    return valid
 
# Get operations for text fields (type 1)
text_ops = get_valid_operations(dc, 1)
print(f"Text operations: {text_ops}")

Constants Module

For frequently used field types, use the constants module:

from dealcloud_sdk.constants import FieldType, get_field_type_name
 
# Using enum
if field.fieldType == FieldType.TEXT:
    print("This is a text field")
 
# Get name from ID
name = get_field_type_name(5)  # "Choice"

Building a Field Type Map

def build_field_type_map(dc):
    """Build ID → name mapping for field types."""
    types = dc.get_field_types()
    return {t['id']: t['name'] for t in types}
 
type_map = build_field_type_map(dc)
 
# Use in field documentation
fields = dc.get_fields("Company")
for f in fields:
    type_name = type_map.get(f.fieldType, "Unknown")
    print(f"{f.apiName}: {type_name}")

Use Cases

Schema Documentation

def document_object_schema(dc, object_id: str):
    """Generate schema documentation."""
    field_type_map = {t['id']: t['name'] for t in dc.get_field_types()}
    fields = dc.get_fields(object_id)
    
    print(f"\n{object_id} Schema")
    print("=" * 50)
    
    for f in sorted(fields, key=lambda x: x.apiName):
        type_name = field_type_map.get(f.fieldType, f"Type {f.fieldType}")
        required = "Required" if f.isRequired else "Optional"
        print(f"  {f.apiName}: {type_name} ({required})")
 
document_object_schema(dc, "Company")

Dynamic Form Builder

def get_form_config(dc, object_id: str):
    """Generate form configuration from schema."""
    field_types = {t['id']: t['name'] for t in dc.get_field_types()}
    fields = dc.get_fields(object_id)
    
    form_fields = []
    for f in fields:
        if f.systemFieldType:  # Skip system fields
            continue
        
        config = {
            "name": f.apiName,
            "label": f.name,
            "type": field_types.get(f.fieldType, "text"),
            "required": f.isRequired,
        }
        
        if f.choiceValues:
            config["options"] = [
                {"value": c.id, "label": c.name}
                for c in f.choiceValues
            ]
        
        form_fields.append(config)
    
    return form_fields
 
form = get_form_config(dc, "Company")

Related