You need to sign in to do that
Don't have an account?
Writing a Test case for Task Trigger ( PLEASE HELP)
Hello Guys,
I Need your help in writing a test case for TaskCreate trigger
My trigger works this way.
For any Task created, an Interaction record is automatically created ... The Interaction Object is a custom Object.
I will like to create a test case for this trigger .. PlEASE HELP, I have tried the Salesforce test case example but to no avail.
Thanks in Advance...
Here is the Code below
trigger TaskCreate on Task (after Insert)
{
List<Interaction__c> INTA = new List<Interaction__c>();
ID RecordTypeofInteraction=[SELECT Id,Name FROM RecordType WHERE Name LIKE '07-Sales Process'].id;
for(Task TC :Trigger.new)
{
INTA.add(new Interaction__c (Subject__c=TC.subject,
Contact__c=TC.whoID,
status__c=TC.Status,
// Adviser__c=TC.WhoID,
//Dealer_Group__c=TC.WhoID,
Log_Interaction_Details__c=TC.description,
Interaction_Type__c='General Information',
recordTypeID = '012Q00000000TqN'));
}
Insert INTA;
}
Let me know if any issues, or if it works ,please mark it solved.
Thanks,
All Answers
Hi,
Try the below test method class as reference(Made changes accordingly)
@isTest
private class testTriggerinsert_Contact_Activity
{
public static testMethod void unitTestinsert()
{
List<Interaction__c> INTA = new List<Interaction__c>();
task t=new task(subject='call',status='completed');
insert t;
}
}
I think this may help...
@isTest
private class testTriggerinsert_Contact_Activity
{
public static testMethod void unitTestinsert()
{
List<Interaction__c> INTA = new List<Interaction__c>();
task t=new task(subject='call',status='completed');
insert t;
Interaction__c intr = [select Id from Interaction__c where Subject__c = ' call' && status__c = 'completed'];
system.asssertEquals(intr.recordtypeId, '012Q00000000TqN');
}
}
This will help you out when the combination of subject and status fields are unique in the schema...
If this fixes your problem, mark it as a solution...
Let me know if any issues, or if it works ,please mark it solved.
Thanks,
Thank you very much guys!
VEry helpful all of you. Even though our company have premuim support Salesforce Tech guys are slow as to respond.
Very Greatful