Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 2

Validation 1:

trigger validation1 on Pharmacist_Application__c (before


insert) {

List<pharmacist_Application__c> list_contain =
[SELECT ID,Email_ID__c FROM
pharmacist_Application__c];
List<String> empty_list = new List<String>();
for(Pharmacist_Application__c con : list_contain){
empty_list.add(con.Email_ID__c);
}
if(trigger.isInsert){
for(Pharmacist_Application__c pho : trigger.new){

if(pho.Email_ID__c != Null){

pho.Email_ID__c.adderror('Enter Email
Address');

}
}
}

Validation 2:
trigger validation3 on Billing_and_Invoice__c (before
insert, before update) {
List<String> list_contain = new List<String>();
List<Billing_and_Invoice__c> list_dml = [SELECT
ID,Patient_s_Email__c FROM Billing_and_Invoice__c];
for(Billing_and_Invoice__c don : list_dml){
list_contain.add(don.Patient_s_Email__c);
}
if(trigger.isInsert){
for(Billing_and_Invoice__c con : trigger.new){
if(list_contain.contains(con.Patient_s_Email__c))
{
con.Patient_s_Email__c.adderror('email
already exist');
}
}
}
if(trigger.update){

You might also like