You need to sign in to do that
Don't have an account?
Strange new apex trigger error inserting campaign members
Hello,
I have a trigger in production in over a dozen salesforce instances. It's an after insert, after update trigger on Opportunity that inserts a campaign member record for the primary contact role if the opportunity has a Primary Campaign Source.
Up until Summer '09, the trigger was working fine but after upgrade starting throwing exceptions:
caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, This entity is already a member of this campaign
Looks to me like inserting duplicate campaign members from a trigger now throws an exception. This used to just fail gracefully and not do anything (i.e. no insert, no exception). Could someone confirm that this is intended functionality? I know that I can always SOQL for existing campaign membership but that's an extra SOQL I'd prefer not to have to do. Just making sure this is intended an not a bug.
Yes,
This is a new behavior; initially if you were trying to insert a member which alredy associated with the same campaign;
it was silently updating the status.
But now it is showing an error, so I think we have to run an extra SOQL or try upsert to mange this.
Regards,
Rajan Jasuja
I am encountering this through campaign member import wizard wizard. What is the workaround for this?
Would you mind sharing the final code that ended up working?