Schema API
Schema Export

Schema Export

Export your DealCloud schema to Excel for documentation, analysis, or sharing.

export_schema_to_excel()

Creates a comprehensive Excel workbook with schema documentation:

from dealcloud_sdk import DealCloud, DealCloudConfig
 
config = DealCloudConfig(
    siteUrl="yoursite.dealcloud.com",
    clientId=12345,
    clientSecret="your-secret",
)
dc = DealCloud.from_config_object(config)
 
# Export full schema
path = dc.export_schema_to_excel("schema_export.xlsx")
print(f"Exported to: {path}")

Output Format

The Excel file contains multiple sheets:

SheetContents
ObjectsAll objects with IDs, names, types
FieldsAll fields with types, properties, references
Choice ValuesChoice field options (optional)
RelationshipsReference field mappings (optional)

Objects Sheet

ColumnDescription
Object IDUnique object ID
Object NameDisplay name
API NameAPI name (for code)
Singular NameSingular display name
Plural NamePlural display name
Entry List TypeObject type category

Fields Sheet

ColumnDescription
Object NameParent object
Field IDUnique field ID
Field NameDisplay name
API NameAPI name (for code)
Field Type IDType ID
Field Type NameType name
Is RequiredRequired flag
Is Multi-SelectMulti-select flag
Is CalculatedCalculated flag
Reference ObjectsTarget objects (references)
DescriptionField description

Choice Values Sheet

ColumnDescription
Object NameParent object
Field NameParent field
Field API NameField API name
Choice IDChoice value ID
Choice NameChoice display name
Parent IDParent choice (hierarchical)

Parameters

ParameterTypeDefaultDescription
filepathstr | PathRequiredOutput .xlsx path
objectsList[str] | NoneAll objectsOptional list of object API names to include
include_summaryboolTrueInclude summary sheet
include_relationshipsboolTrueInclude relationships sheet

The workbook layout (summary, per-object sheets, relationships) is produced by the SDK implementation of export_schema_to_excel() in dealcloud_sdk, not the legacy parameter names output_path / include_choice_values.

Examples

Full Export

# Export everything
dc.export_schema_to_excel("full_schema.xlsx")

Selected Objects

# Export specific objects only
dc.export_schema_to_excel(
    "crm_schema.xlsx",
    objects=["Company", "Contact", "Deal", "Interaction"]
)

Toggle summary or relationships sheets

# Summary only, skip relationships sheet
dc.export_schema_to_excel(
    "schema_no_rel.xlsx",
    include_summary=True,
    include_relationships=False,
)

Minimal path export

dc.export_schema_to_excel("schema_minimal.xlsx")

Use Cases

Documentation

# Generate schema documentation for a new project
dc.export_schema_to_excel(
    f"schema_{dc.site_url.split('.')[0]}_{datetime.now():%Y%m%d}.xlsx",
)

Compare Environments

# Export from multiple environments
for env in ["prod", "staging", "dev"]:
    dc = DealCloud.from_json(f"config_{env}.json")
    dc.export_schema_to_excel(f"schema_{env}.xlsx")
 
# Then compare Excel files manually or programmatically

Data Dictionary

from pathlib import Path
 
def create_data_dictionary(dc, output_dir: str):
    """Create comprehensive data dictionary."""
    output = Path(output_dir)
    output.mkdir(exist_ok=True)
    
    # Full schema
    dc.export_schema_to_excel(output / "full_schema.xlsx")
    
    # Per-object exports
    objects = dc.get_objects()
    for obj in objects:
        dc.export_schema_to_excel(
            output / f"{obj.apiName}_schema.xlsx",
            objects=[obj.apiName]
        )
    
    print(f"Created data dictionary in {output}")
 
create_data_dictionary(dc, "./data_dictionary")

Integration Mapping

def create_integration_map(dc, target_system_fields: dict, output_path: str):
    """
    Create mapping document between DealCloud and external system.
    
    target_system_fields: Dict of {dc_api_name: external_field_name}
    """
    import pandas as pd
    
    schema = dc.get_schema()
    
    mapping = []
    for obj_name, obj_data in schema.objects.items():
        for field_name, field in obj_data.fields.items():
            external = target_system_fields.get(f"{obj_name}.{field_name}")
            mapping.append({
                "DC Object": obj_name,
                "DC Field": field_name,
                "DC Display": field.name,
                "DC Type": field.fieldType,
                "External Field": external or "",
                "Mapped": "Yes" if external else "No"
            })
    
    df = pd.DataFrame(mapping)
    df.to_excel(output_path, index=False)
 
# Usage
field_map = {
    "Company.CompanyName": "account_name",
    "Company.Industry": "industry_code",
    "Contact.Email": "email_address",
}
create_integration_map(dc, field_map, "integration_mapping.xlsx")

Custom Export

For custom formats, use get_schema() directly:

import pandas as pd
 
def custom_schema_export(dc, output_path: str):
    """Custom schema export with specific formatting."""
    schema = dc.get_schema()
    
    with pd.ExcelWriter(output_path, engine='openpyxl') as writer:
        # Custom objects sheet
        objects_data = []
        for name, obj in schema.objects.items():
            objects_data.append({
                "API Name": name,
                "Display Name": obj.object.pluralName,
                "Field Count": len(obj.fields),
                "Has Attachments": any(f.isAttachment for f in obj.fields.values())
            })
        
        pd.DataFrame(objects_data).to_excel(writer, sheet_name="Objects", index=False)
        
        # Custom fields sheet per object
        for name, obj in schema.objects.items():
            if len(obj.fields) > 0:
                fields_data = [
                    {
                        "API Name": f.apiName,
                        "Display": f.name,
                        "Type": f.fieldType,
                        "Required": "✓" if f.isRequired else "",
                    }
                    for f in obj.fields.values()
                ]
                pd.DataFrame(fields_data).to_excel(
                    writer, 
                    sheet_name=name[:31],  # Excel sheet name limit
                    index=False
                )
 
custom_schema_export(dc, "custom_schema.xlsx")

Related