I have a trigger in place that runs for every order record created. I need this trigger to only run when for specific record types. I am not sure if by my trigger and test class needs to be updated of is only the trigger needs to be updated to reflect this change
Test Class:
@isTest
public class Test_orderAfterInsert {
public static testmethod void test_method1(){
Account a = new Account();
a.name = 'test';
insert a;
case c = new case();
c.AccountId = a.Id;
c.origin = 'Phone';
insert c;
Orders__c ord = new Orders__c();
ord.Related_Account__c = a.Id;
ord.Related_Case__c = c.Id;
//Orders__c or = new Orders__c();
//or.Account__c = a.Id;
insert ord;
}
Apex Trigger:
trigger orderAfterInsert on Orders__c (after insert) {
string caseId;
list<Case> lstToUpdateCase = new list<Case>();
//Assigning caseid in variable
for(Orders__c ord : Trigger.New)
{
caseId = ord.Related_Case__c;
}
//updating case record with the caseid
case c = new case(id = caseId);
c.Order_Created__c = true;
//adding order created into list
lstToUpdateCase.add(c);
//updating the record through DML operation
if(lstToUpdateCase.Size()>0)
{
update lstToUpdateCase;
}
}