AllowFieldTruncationHeader

The AllowFieldTruncationHeader header specifies the truncation behavior of the following field datatypes that contain strings:

In API versions previous to 15.0, if you specify a value for a field that is one of the datatypes listed, and that value is too large, the value is truncated. For API version 15.0 and later, if a value is specified that is too large, the operation fails and the fault code STRING_TOO_LONG is returned. AllowFieldTruncationHeader allows you to specify that the previous behavior, truncation, be used instead of the new behavior in API versions 15.0 and later. This header has no effect in versions 14.0 and earlier.

API Calls

convertLead(), create(), merge(), process(), undelete(), update(), and upsert()

Apex: executeanonymous()

Fields

Element Name Type Description
allowFieldTruncation boolean If true, truncate field values that are too long, which is the behavior in API versions 14.0 and earlier.

Default is false: no change in behavior. If a string or textarea value is too large, the operation fails and the fault code STRING_TOO_LONG is returned.

The following list shows the field types affected by truncation and this header:

  • anyType, if it represents one of the other datatypes in this list
  • email
  • encryptedstring
  • mulitpicklist
  • phone
  • picklist
  • string
  • textarea

Sample

public void allowFieldTruncationSample() {
  try {
    Account account = new Account();
    // Construct a string that is 256 characters long.
    // Account.Name's limit is 255 characters.
    String accName = "";
    for (int i = 0; i < 256; i++) {
      accName += "a";
    }
    account.setName(accName);
    // construct an array of SObjects to hold the accounts
    SObject[] sObjects = new SObject[1];
    sObjects[0] = account;
    // Attempt to create the account. it will fail in 15.0
    // and above because the account name is too long.
    SaveResult[] results = connection.create(sObjects);
    System.out.println("The call failed because: "
       + results[0].getErrors()[0].getMessage());
    // Now set the SOAP header to allow field truncation
    connection.setAllowFieldTruncationHeader(true);
    // Attempt to create the account now.
    results = connection.create(sObjects);
    System.out.println("The call: " + results[0].isSuccess());
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }
}
© Copyright 2000–2012 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.