I am trying to build a after insert
trigger on Contract
object. Whenever user will create a Contract
record trigger will generate/insert record of other object called Dim2
. Dim2
have a lookup with Contract
.
Here is my Trigger
trigger Contract2DIM2 on Contract (after insert) {
if(Trigger.isInsert){
for(Contract c : Trigger.New) {
C2D2.insertDim2(c.ContractNumber);
}
}
Here is my class
public class C2D2 {
public static void insertDim2(String Cnumber){
try{
c2g__codaDimension2__c a=new c2g__codaDimension2__c();
a.Name=Cnumber;
a.c2g__ReportingCode__c=Cnumber;
a.Contract_Reference__c=Cnumber;
insert a;
}catch(dmlexception e){
system.debug('galti'+e.getMessage());
}
}
}
It gives the following Error