Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
All errors
Deployment

Cannot change field type from <type1> to <type2> via the API

Salesforce restricts which field type changes are allowed in a deploy. Many type transitions (Number to Text, Picklist to Lookup, Text to Long Text Area, etc.) require a UI-based wizard with data migration. The deploy fails until you make the change via the UI or a destructive-create cycle.

Also seen asCannot change field type·field type cannot be changed·field type change not allowed

Salesforce field-type changes have three classes:

  1. Allowed automatically in deploy — small changes like Text length increase, picklist value additions
  2. Allowed but with caveats — Text → Long Text Area, Number precision changes (in some directions)
  3. Not allowed via API — anything that would lose data or change the underlying storage

Hit class 3 in a deploy and you get this error.

Allowed via API

From → ToNotes
Text(50) → Text(100)Length increase, fine
Number(10,2) → Number(12,2)Precision increase, fine
Picklist (add values)Adding values is fine
Restricted Picklist toggle offTurn off Restricted, fine

Not allowed via API (need UI or destructive)

From → ToWhy
Text → Long Text AreaDifferent storage
Long Text Area → TextData truncation risk
Number → TextDifferent storage
Picklist → Multi-Select PicklistDifferent storage shape
Picklist → LookupUnderlying type change
Lookup → Master-DetailMajor behavior change
Master-Detail → LookupSame — children un-cascade
Encrypted toggleOne-way change

How to do an unsupported change

Option 1: UI wizard

For changes the platform supports interactively, use the Setup → Object → Fields → field → Change Field Type wizard. The platform walks you through data migration, asks which value to use for converted records, etc.

After the change, retrieve the new field metadata from the org and replace your repo's version.

Option 2: Destructive-create cycle

For genuinely unsupported changes:

  1. Create a new field with the new type (e.g., Description_New__c)
  2. Migrate data with a one-shot Apex job:
    List<Account> accounts = [SELECT Id, Description, Description_New__c FROM Account];
    for (Account a : accounts) {
        a.Description_New__c = a.Description == null ? null : a.Description.left(255);
    }
    update accounts;
    
  3. Repoint code to use the new field
  4. Delete the old field (destructive change)
  5. Rename Description_New__cDescription__c (or just keep the new name)

Each step is a separate deploy. The data migration step typically runs in a sandbox first.

A subtle case: API version changes

Some field types were added in specific API versions. If your deploy uses a sourceApiVersion older than the type's introduction, you may see this error. Bump the version.

For example, Time fields are API 50.0+. Deploying a Time field with API 49.0 fails.

When the error is misleading

Sometimes the platform reports "Cannot change field type" when the actual issue is something else — a related dependency, a profile permission, etc. Read the full error message, not just the headline. Salesforce often includes a more specific reason after the headline.

Avoid type changes by design

Custom Metadata Types and Custom Settings are more flexible than custom fields for changing schemas. If you anticipate a field type might change, store it as Custom Metadata from the start.

Related dictionary terms