String attribute overflowing
This page was created by Lars.olofsson on 2022-06-30. Last edited by Stephanie on 2025-02-12.
If you MDrivenServer log contains errors like
String or binary data would be truncated
You have OCL code or a part of your system in general that puts a too long text into a attribute and then tries to save it.
The rest of the message might be like
@errorinfo=S_OutgoingEmail.SS_OutgoingEma... (length=1153) (System.String) (DbType: String)
In this example, the problem is that the serverside email action gets an exception and tries to write that error message to a too short string attribute.
You have two options, and you should probably use both;
- Make the string attribute longer to capture what you want to store
- Include code that makes sure you don't overflow the attribute
Use the following OCL to always ensure that you never try to write a too long string.
<attribute>.subString(1,<attribute>.maxLength-1)
For the example above;
self.errorinfo.subString(1,self.errorinfo.maxLength-1)