You need to sign in to do that
Don't have an account?
Jagadeesh M 1
Need help on validation rule/ apex code at least on check box need to selected
Hi All ,
I have a requirement On validation rule /Apex Code :
I need to select at lease one check box to be selected in the multiple row, if not we have to through as error message as must be select on check box.
Are let us know any possible apreouches.Your quick responce would be greatly apreacites...!!!
Thanks,
M. Jagadeesh
I have a requirement On validation rule /Apex Code :
I need to select at lease one check box to be selected in the multiple row, if not we have to through as error message as must be select on check box.
Are let us know any possible apreouches.Your quick responce would be greatly apreacites...!!!
Thanks,
M. Jagadeesh
At least one check box need to be selected from the panel. If any check box is not selected through an error.
Let me explain more:
User may add any no. of rows, each row having the one check box. If the user not select any check box click no go button, we have to diplay error that need to select at least one check box.
OR(checkbox_1__c, checkbox_2__c, checkbox_3__c)
I don't remember if the checkbox should equals to "true" in validation, so if that doesn't work, try adding the " = True "
IF(checkbox1 || checkbox2 || checkbox3){
/* do something */
} else {
ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR, 'You need to pick at least 1 of the options');
ApexPages.addMessage(errorMessage)
}
(need to have <apex:message /> <apex:messages /> in your VF page)
ICP_DFD_Member__c fcMember = (ICP_DFD_Member__c)ICP_DFD_Member__c.sObjectType.newSObject(null, true);
fcMember.ICPDFD_Application__c=app.ID;
list<ICP_DFD_Member__c> payeeList = [select Id,FIRST_NAME__c, LAST_NAME__c,GENDER__c, Payee__c from ICP_DFD_Member__c]; //where ICP_DFD_Member__c.ICPDFD_Application__c = app.ID
system.debug('<<<EnterSaveNext and Payee Total List<<' + payeeList) ;
for(integer i =0; i < payeeList.size(); i++)
{
if(fcMember.Payee__c== false)
{
save(true);
}
else
{
system.debug('<<<EnterSaveNext<<' ) ;
isSaveSuccessful = false;
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Please select the Payee'));
}
}
On your loop, you are telling the code that if payee is NOT selected, it should save the register. If it is, it should throw an error that says "select the payee" ... Is the "payee" field a checkbox field? or which fields are the checkboxes?
(PS: is "cleaner" to put statements like " IF(!fcMember.Payee__c) more than IF(fcMember.Payee__c == False) )