Milcho Dimkov
09/13/2024, 12:55 PMCeligo AI
09/13/2024, 12:56 PMAI generated answer (using internal Slack threads):Based on the conversations, you can create a client script that runs on a suitelet and raises an error message if the field 'custpage_myfield' has less than 5 characters entered in it. You can use the
fieldChanged
event to trigger this validation. Here is a sample code:
javascript
define(['N/record', 'N/ui/message', 'N/currentRecord'],
function(record, message, currentRecord) {
function fieldChanged(context) {
if (context.fieldId === 'custpage_myfield') {
var fieldValue = context.currentRecord.getValue({
fieldId: 'custpage_myfield'
});
if (fieldValue.length < 5) {
var myMsg = message.create({
title: "Error",
message: "Field 'custpage_myfield' must have at least 5 characters",
type: message.Type.ERROR
});
myMsg.show();
}
}
}
return {
fieldChanged: fieldChanged
};
});
In your suitelet, you need to set the client script file path to the clientScriptModulePath
property of the form:
javascript
form.clientScriptModulePath = 'SuiteScripts/yourClientScript.js';
Remember to replace 'SuiteScripts/yourClientScript.js'
with the actual path to your client script file.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
09/13/2024, 12:57 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82019
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816660404
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815083206
Celigo AI
09/13/2024, 12:57 PM