You need to sign in to do that
Don't have an account?
agier
Moving SOQL query outside For statement
Would appreciate any advice on how to best re-write this trigger so I don't hit the SOQL limits on bulk loading. It works well for creating individual records. Thanks!
I apologize the browser/message board won't allow me to format my posting so I am pasting it in text...
12345678 trigger ContactDuplicateTriggerOfficePhone on Contact (before insert) {for (Contact c : Trigger.new){Contact[] contacts= [select id from Contact where NameOffice_Combo__c=:c.NameOffice_Combo__c and NameOffice_Combo__c != ''];if (contacts.size() > 0) {c.LastName.addError('Contact cannot be created. A contact already exists with the same name/office phone combination.');} }}
Below should do it.
All Answers
Below should do it.
Wow - thanks! I really appreciate it. I'm sure this is relatively simple but I am not skilled in Apex. I will try this out. One more question - how do I get the existing trigger deleted or deactivated if it is already in production?
Hi,
You can delete the trigger from prodcution using eclipse ide. Just create a new project in eclipse ide with your production credentials, choose the required triggers via add or remove metadata components. Then, after you are done with creating a project, in the ide drill down to the triggers and the trigger that you want to delete, right click on the trigger that you want to delete and choose delete option. It would prompt you ' are you sure you want to delete file blahblah.trigger' press ok and it would again prompt you weather to delete the file locally or on the server as well. choose the one you want and it would take solid amount of time to get deleted (time is around 10-25mins) for each trigger individually.
Thanks.
If you are replacing it with this - just update the code in the sandbox and push to production.
Thank you!
I just got to testing this new trigger and received the following error...
Sorry was a typo... i'll amend my post above - try the following:
Thank you very much!! I've been able to use this successfully and modify it to address 6 other triggers I had written! I have one more that is written a little differently and am not sure how to modify this one...
NP, give this a try
Thanks for your help! I couple errors came up:
i thought perhaps it was an extra bracket but when I remove it, then i get:
It was missing a close parentheses...
Awesome! Thanks again for all your help!!