+ Start a Discussion
Junker52Junker52 

Trigger trouble with the NPSP and blockDuplicates_tgr

Trying to allow our volunteers to update their email address through our website. They are logging in through drupal where their email and other information is stored and synced with SF. If they change their email address on the web-page, drupal passes that over to SF and that's where it fails. Salesforce will not allow us to change an email on a "record", (contact really, because we're running the NPSP). It always returns the error message, "a contact with this email already exists" which of course is not true.

If I delete the blockDuplicates_tgr it will allow me to update an email, though obviously that is not really the best idea. Any help would be greatly appreciated.

SanjaySSanjayS

This might be due to the way trigger may be written I think that its after update trigger.  The 'after' trigger fires after the records are saved/updated  into the database. You may have to tweak the trigger where you are checking for the existence of the email address.

sandeep@Salesforcesandeep@Salesforce

It seems to be a coding mistake I think We are trying to insert one record two times so exception is coming as "duplicate Email Address" 

Junker52Junker52

So is there a way to tweak it or is deleting my only option?

SanjaySSanjayS

You can use a 'before' trigger  instead of 'after' trigger if you think that it is not going to change any logic in the code.

Basically if you are looking to find a email address  you updated in 'after' trigger the email address will already be there and your code will fail everytime. It should not be a big change. 

Other option is to move the code (where you are checking if the email is existing or not) to a before trigger. You can write multiple triggers (but not  a good practice).