You need to sign in to do that
Don't have an account?

Inserting contactrole on opp creation but getting error:
Here is a trigger :
Error msg:Review all error messages below to correct your data.
Apex trigger ContactroleonOpp caused an unexpected exception, contact your administrator: ContactroleonOpp: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Contact ID: id value of incorrect type:
trigger ContactroleonOpp on Opportunity (after insert) { list <OpportunityContactRole > i = new list <OpportunityContactRole >(); for(Opportunity newopp : trigger.new){ if (newopp.id != null ){ i.add(new OpportunityContactRole ( OpportunityId = newopp.id, //accountname = newopp.AccountId, ContactId = newopp.AccountId, Role = 'Other', IsPrimary = true)); } } insert i ; }
Error msg:Review all error messages below to correct your data.
Apex trigger ContactroleonOpp caused an unexpected exception, contact your administrator: ContactroleonOpp: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, Contact ID: id value of incorrect type:
If this helps, please mark the solution green.
Cheers,Dev