You need to sign in to do that
Don't have an account?
sai_kumar_sfdc1.3903397698928884E12
Need Test for Opp Trigger
Need help on creating Test class for below Class?
Urgent Help please on this
public class OpportunityUpdateEmailHelper{
public static void updatePrimaryEmailtoOpportunity(List<opportunity> ops)
{
for(opportunity opp:ops)
{
if(opp.StageName=='Closed Won')
{
system.debug('$****************:'+opp.StageName+'::');
String wonOppId=opp.id;
List<OpportunityContactRole> availablecontacts = [SELECT Id, ContactId, OpportunityId from OpportunityContactRole where OpportunityId = :wonOppId AND IsPrimary=true];
if (availablecontacts.size()==0) return;
system.debug('$****************:'+availablecontacts[0].contactId+'::');
String primarycontactId=availablecontacts[0].contactId;
List<Contact> availablecontact = [SELECT Id, Email from Contact where Id = :primarycontactId];
if (availablecontact.size()==0) return;
system.debug('$****************:'+availablecontact[0].Email+'::');
String sendemailto=availablecontact[0].Email;
opp.Primary_Contact_Email__c=sendemailto;
}
}
}
}
Urgent Help please on this
public class OpportunityUpdateEmailHelper{
public static void updatePrimaryEmailtoOpportunity(List<opportunity> ops)
{
for(opportunity opp:ops)
{
if(opp.StageName=='Closed Won')
{
system.debug('$****************:'+opp.StageName+'::');
String wonOppId=opp.id;
List<OpportunityContactRole> availablecontacts = [SELECT Id, ContactId, OpportunityId from OpportunityContactRole where OpportunityId = :wonOppId AND IsPrimary=true];
if (availablecontacts.size()==0) return;
system.debug('$****************:'+availablecontacts[0].contactId+'::');
String primarycontactId=availablecontacts[0].contactId;
List<Contact> availablecontact = [SELECT Id, Email from Contact where Id = :primarycontactId];
if (availablecontact.size()==0) return;
system.debug('$****************:'+availablecontact[0].Email+'::');
String sendemailto=availablecontact[0].Email;
opp.Primary_Contact_Email__c=sendemailto;
}
}
}
}
The whole idea is to simulate the app behavior on your test class. For example if your test class interacts with Account records, you need to create account records in your test class programmatically and then instantiate the class you are testing and call it's methods.
Hope that helps.