Function to count the characters of the company name, and it will show an alert message if the character count exceeds 74.
function characterCount(scriptContext) {
let vendorName = scriptContext.currentRecord.getValue({
fieldId: 'companyname'
});
let vendorNameCount = vendorName.length;
scriptContext.currentRecord.setValue({
fieldId: 'custentity_jj_name_char_count',
value: vendorNameCount
});
if (vendorNameCount > 74) {
let countRem = vendorNameCount - 74;
alert("Company name can't be greater than 74 characters. Reduce " + countRem + " character(s).");
return false;
} else {
return true;
}
}