Skip to main content

accommodate Accommodate the length of a string value to prevent the STRING_TOO_LONG issue

I received an exception while trying to insert an Order Itemorder item. It appears to be that the Descriptiondescription field allows only 255 characters,characters; sometimes my descriptions goes beyond 255.

I will shorten the length of the description before inserting the entry. See the code as follows:

Order ord = new Order(.....);

String description = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, ';

if(description.length() > 255){
    description = description.abbreviate(255);
}

ord.Description = description;

insert ord;

I am wondering whether there is an easier way to accomplish this by using the Salesforce built-in features. Meaning without writing code.

accommodate the length of a string value to prevent STRING_TOO_LONG issue

I received an exception while trying to insert an Order Item. It appears to be that the Description field allows only 255 characters, sometimes my descriptions goes beyond 255.

I will shorten the length of the description before inserting the entry. See code as follows:

Order ord = new Order(.....);

String description = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, ';

if(description.length() > 255){
    description = description.abbreviate(255);
}

ord.Description = description;

insert ord;

I am wondering whether there is an easier way to accomplish this by using the Salesforce built-in features. Meaning without writing code.

Accommodate the length of a string value to prevent the STRING_TOO_LONG issue

I received an exception while trying to insert an order item. It appears to be that the description field allows only 255 characters; sometimes my descriptions goes beyond 255.

I will shorten the length of the description before inserting the entry. See the code as follows:

Order ord = new Order(.....);

String description = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, ';

if(description.length() > 255){
    description = description.abbreviate(255);
}

ord.Description = description;

insert ord;

I am wondering whether there is an easier way to accomplish this by using the Salesforce built-in features. Meaning without writing code.

Tweeted twitter.com/StackSalesforce/status/1030560124556005376
Source Link
Cuban coffee
  • 1.6k
  • 1
  • 27
  • 57

accommodate the length of a string value to prevent STRING_TOO_LONG issue

I received an exception while trying to insert an Order Item. It appears to be that the Description field allows only 255 characters, sometimes my descriptions goes beyond 255.

I will shorten the length of the description before inserting the entry. See code as follows:

Order ord = new Order(.....);

String description = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, ';

if(description.length() > 255){
    description = description.abbreviate(255);
}

ord.Description = description;

insert ord;

I am wondering whether there is an easier way to accomplish this by using the Salesforce built-in features. Meaning without writing code.