You need to sign in to do that
Don't have an account?
Shantanu Mahajan
Salesforce Apex trigger
in below code example i want to compare the e-mail and contact number of customer and complaint object. complaint and customer are in lookup relationship. i want output like if before registering a compliant it should check the same e-mail address and phone number must be in customer record.
trigger Demo on Complaint__c (before insert) {
if(trigger.isBefore)
{
if(trigger.isInsert)
{
for(Shan__Complaint__c a:Trigger.new)
{
for(Shan__bsnl_customer__c b:Trigger.new)
if(a.Shan__Phone_Number_del__c== b.Shan__cust_contact__c && a.Shan__E_mail_del__c==b.Shan__cust_email__c)
{
a.adderror('Customer is not in Database');
}
}
}
trigger Demo on Complaint__c (before insert) {
if(trigger.isBefore)
{
if(trigger.isInsert)
{
for(Shan__Complaint__c a:Trigger.new)
{
for(Shan__bsnl_customer__c b:Trigger.new)
if(a.Shan__Phone_Number_del__c== b.Shan__cust_contact__c && a.Shan__E_mail_del__c==b.Shan__cust_email__c)
{
a.adderror('Customer is not in Database');
}
}
}
what i understand is there are 2 object :
customer and complaint
now before enetring the complaint you want the field( phone,email) on complaint object to match with fields on customer object if so , only then enter complaimnt record else .. add error
is this the requirement ?
Match the variable name according to you requiremnts :
and let me know .
Thanks :)