[SalesForce] How to resolve CANNOT_INSERT_UPDATE_ A workflow or approval field update caused an error when saving this record. Order Name: data value too large:

I have a trigger code and I am trying to insert large data on Order Name. I get the below error:

Update failed. First exception on row 0 with id 8014B000000HkuPQAS;
first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, OSM_OrderTrigger:
execution of AfterUpdate caused by: System.DmlException: Update
failed. First exception on row 0 with id 8024B000000JxXQQA0; first
error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, A workflow or approval
field update caused an error when saving this record. Contact your
administrator to resolve it. Order Name: data value too large: Order
(max length=80):

How to do I resolve this issue?

Best Answer

You put split the name and then put the name in field. You can try the following piece of code in your trigger.

String str = 'kjsbjkcbjkadbscjkbjkabscbabcbsakbcjkbsabclkbaskjcbkcsvdgcjsvdcjhsdvchjsdhvchjsdvhjcsdjcbajcascascajnckjnjjkBCKJbkjckjnzkjckjdskjcbkbdskc';
str= str.substring(0,80);
System.debug(str);
campaign  camp=new campaign ();
camp.name=str;
insert camp;
Related Topic