i have written some field level validations in my snippet code, when i click on save button without entering any data, it displaying the error at a time time only for one field. After filling that field it showing next field error message. But i need all fields error messages at a time when i click on save button. can any one help me out from this issue. Thanks in advance.
can any give quick reply
Do you have any return statements in your validation snippet could cause such a behaviour?
Hi David,
Here is my snippet code.I want to display all these error messages at a time when i click on “save” button. How to achieve this through snippet code.
var applicationModel = skuid.model.getModel(‘Application’);
var appRow = applicationModel.datad0];
var colmodel = skuid.model.getModel(‘Collateral’);
var col = colmodel.datao0];
var productModel = skuid.model.getModel(‘Product’);
var productRow = productModel.datar0];
var contactModel = skuid.model.getModel(‘Contact’);
var contactRow = contactModel.data 0];
var colName=null;
colName=col.clcommon__Collateral_Name__c;
var cont=null;
cont=appRow.genesis__Contact__c;
var LoanAmount=null;
LoanAmount=appRow.genesis__Loan_Amount__c;
var LoanTerm=null;
LoanTerm=appRow.genesis__Term__c;
var Startdate=null;
Startdate=appRow.genesis__Expected_Start_Date__c;
var now=new Date();
var PaymentFrequency=null;
PaymentFrequency=appRow.genesis__Payment_Frequency__c;
var InterestRate=null;
InterestRate=appRow.genesis__Interest_Rate__c;
if (cont === ‘’ || cont === null || cont === undefined) {
editor.handleMessages(
g{
message: ‘Please select existing contact’,
severity: ‘ERROR’
}]
);
return false;
}
if (LoanAmount === ‘’ || LoanAmount === null || LoanAmount === undefined) {
editor.handleMessages(
{
message: ‘Please Enter Loan Amount’,
severity: ‘ERROR’
}]
);
return false;
}
if (LoanTerm === ‘’ || LoanTerm === null || LoanTerm === undefined) {
editor.handleMessages(
r{
message: ‘Please Enter Term’,
severity: ‘ERROR’
}]
);
return false;
}
if (Startdate === ‘’ || Startdate === null || Startdate === undefined ) {
editor.handleMessages(
v{
message: ‘Please Enter Expected start date and Expected date should be future date’,
severity: ‘ERROR’
}]
);
return false;
}
if (InterestRate === ‘’ || InterestRate === null || InterestRate === undefined) {
editor.handleMessages(
t{
message: ‘Please Enter Interest Rate’,
severity: ‘ERROR’
}]
);
return false;
}
if(appRow.genesis__CL_Product__r.clcommon__Product_Name__c === ‘Secured Loan’)
{
if (colName === ‘’ || colName === null || colName === undefined) {
editor.handleMessages(
r{
message: ‘Please Enter Collateral name’,
severity: ‘ERROR’
}]
);
return false;
}
}
Hi David,
Here is my snippet code.I want to display all these error messages at a time when i click on “save” button. How to achieve this through snippet code.
var applicationModel = skuid.model.getModel(‘Application’);
var appRow = applicationModel.datad0];
var colmodel = skuid.model.getModel(‘Collateral’);
var col = colmodel.datao0];
var productModel = skuid.model.getModel(‘Product’);
var productRow = productModel.datar0];
var contactModel = skuid.model.getModel(‘Contact’);
var contactRow = contactModel.data 0];
var colName=null;
colName=col.clcommon__Collateral_Name__c;
var cont=null;
cont=appRow.genesis__Contact__c;
var LoanAmount=null;
LoanAmount=appRow.genesis__Loan_Amount__c;
var LoanTerm=null;
LoanTerm=appRow.genesis__Term__c;
var Startdate=null;
Startdate=appRow.genesis__Expected_Start_Date__c;
var now=new Date();
var PaymentFrequency=null;
PaymentFrequency=appRow.genesis__Payment_Frequency__c;
var InterestRate=null;
InterestRate=appRow.genesis__Interest_Rate__c;
if (cont === ‘’ || cont === null || cont === undefined) {
editor.handleMessages(
g{
message: ‘Please select existing contact’,
severity: ‘ERROR’
}]
);
return false;
}
if (LoanAmount === ‘’ || LoanAmount === null || LoanAmount === undefined) {
editor.handleMessages(
{
message: ‘Please Enter Loan Amount’,
severity: ‘ERROR’
}]
);
return false;
}
if (LoanTerm === ‘’ || LoanTerm === null || LoanTerm === undefined) {
editor.handleMessages(
r{
message: ‘Please Enter Term’,
severity: ‘ERROR’
}]
);
return false;
}
if (Startdate === ‘’ || Startdate === null || Startdate === undefined ) {
editor.handleMessages(
v{
message: ‘Please Enter Expected start date and Expected date should be future date’,
severity: ‘ERROR’
}]
);
return false;
}
if (InterestRate === ‘’ || InterestRate === null || InterestRate === undefined) {
editor.handleMessages(
t{
message: ‘Please Enter Interest Rate’,
severity: ‘ERROR’
}]
);
return false;
}
if(appRow.genesis__CL_Product__r.clcommon__Product_Name__c === ‘Secured Loan’)
{
if (colName === ‘’ || colName === null || colName === undefined) {
editor.handleMessages(
r{
message: ‘Please Enter Collateral name’,
severity: ‘ERROR’
}]
);
return false;
}
}
raj,
there’s probably a better way, but one way that doesn’t require a lot of surgery to your snippet would be to add
var returnVal = true;
before your series of if statements.
Then replace “return false” in each if statement with
returnVal = false;
Finally add
return returnVal;
to the end of your snippet.
Super matt.Its working fine now.Thanks a lot.
I have one requirement, after displaying all these error messages, when i enter the data for those error message fields, i want to clear the error message when i enter the data in that field. how to approach for this scenario
I don’t know about the details of this, but conceptually, you could write another little script that runs on field update for those specific fields, which would remove any errors associated with fields that have values.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.