Issue
When entering a multi-line text (using multiple ‘Enters’) into a text field that has a defined maximum character limit, the system displays a character count indicating that the input is within the allowed limit. However, when the user attempts to submit the form, the following error is displayed:
ORA-12899 value too large for column string (actual: string, maximum: string)
https://docs.oracle.com/en/error-help/db/ora-12899/?r=26ai
Steps to reproduce
-
Configure the Text Area Field with 'Max characters' limit.
-
Add input into the Text Area field.
-
Check the characters count displayed.
-
Verify that character count is different in the DB.
-
Click Submit.
Root Cause
The database is counting 'Enter' as two characters. For Pega, ‘Enter’ is counted as one character and for some standards it is ‘Carriage Return + Line Feed’ (two characters) as in this instance in the database.
Workaround
Perform one of the following methods as a workaround:
- Increase the column size on the database side.
- Or, include the script below in the userworkform rule. This script considers the Enter key as two characters on the client side.
<script>
if(pega.control.ITextArea) {
pega.control.ITextArea.prototype.keydown = function(event) {
var eventEle = event.target;
var tempValue = eventEle.value.replace(/\n/g,"\r\n");
var charMaxValue = eventEle.getAttribute("maxLength");
if(charMaxValue){
charMaxValue = parseInt(charMaxValue);
var keyCode = event.keyCode;
if((keyCode == 13 && (tempValue.length + 2) > charMaxValue) || (keyCode != 8 && (tempValue.length + 1) > charMaxValue)) {
event.preventDefault();
}
}
};
pega.control.ITextArea.prototype.updateTextAndCounter = function(eventEle) {
if(eventEle.nodeName.toUpperCase() == "TEXTAREA") {
var charMaxValue = eventEle.getAttribute("maxLength");
var tempValue = eventEle.value.replace(/\n/g,"\r\n");
if(charMaxValue){
charMaxValue = parseInt(charMaxValue);
var isMicrosoftEdge = navigator.userAgent.match(/Edge/ig);
if(tempValue.length > charMaxValue && (!("maxLength" in document.createElement("TEXTAREA")) || isMicrosoftEdge )) {
if (eventEle.value.length > tempValue.length) {
eventEle.value = eventEle.value.substring(0,charMaxValue + (eventEle.value.length - tempValue.length));
} else {
eventEle.value = eventEle.value.substring(0,charMaxValue);
}
this.valueReset = true;
}
eventEle.value = tempValue;
}
if(eventEle.getAttribute("updateCounter") == "true") {
var counterSpan = document.getElementById(eventEle.id+"_counter");
if(counterSpan){
counterSpan.innerHTML = ((charMaxValue - tempValue.length) < 0 ? 0 :(charMaxValue - tempValue.length));
}
}
}
};
}</script>
Solution
This issue is planned to be addressed in a future Pega Platform release. Issues are prioritized based on impact, severity, and capacity. This section will be updated with release details when the fix for this issue is available.
Related Content
-
Search for CRLF in MDN Web Docs
-
Search for ORA-12899 in Oracle Help center