The below trigger : Lead and Contact have same checkbox fields, both object fields should have same value
trigger checktheLeadCheckBox on Contact (after update)
{
for(Contact c : Trigger.New)
{
List<Lead> li = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Lead where Email =: c.Email AND IsConverted =: false];
for(Lead l : li)
{
If(l.Id != null)
{
l.Customer_of_PubKCyber__c=c.Customer_of_PubKCyber__c;
l.Customer_of_PubKLaw__c = c.Customer_of_PubKLaw__c;
update l;
}
}
}
}
Trigger 2
The below trigger : checking the value of the checkboxes on Contacts object based on a condition
Please give me the test class to cover 75 of code coverage to migration.......Very CriticalPlease give me the test class to cover 75 of code coverage to migration.......Very Criticaltrigger updatecontactcheckbox on Opportunity (after insert, after update)
{
for(Opportunity o : Trigger.New)
{
if( o.Contact__c != null)
{
Contact c = [select Id, Customer_of_PubKCyber__c,Email,Customer_of_PubKLaw__c from Contact where Id =: o.Contact__c ];
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKCyber Newsletter'))
{
c.Customer_of_PubKCyber__c = True;
}
else if(o.Product_Name__c == 'PubKCyber Newsletter')
{
c .Customer_of_PubKCyber__c = false;
}
if((o.Subscription_Start_Date__c <= System.Today()) && (o.Subscription_End_Date__c >= System.Today()) && (o.Product_Name__c == 'PubKLaw Newsletter'))
{
c.Customer_of_PubKLaw__c= True;
}
else if(o.Product_Name__c == 'PubKLaw Newsletter')
{
c.Customer_of_PubKLaw__c = false;
}
update c;
}
}
}