
to make it a bit more complicated we have a duplication catcher that runs whenever a new account is created.
So, multiple questions.
1. Can we create a trigger to generate the new account when a case is created,
2. What happens if the dup catcher fires to prevent the new account due to a duplicate?
Now to make it more complex, we would also like to create a new contact if the peson in the case does not exist in salesforce. Again the dup catcher will fire, and moreover, I understand that trigges don't fire in any predetermined order, so is ther a way to always create the account first and then capture the new account id , and then create the new contact? Would that be two triggers? One on the acse and one on the account?
답변 2개
Well this all possible! You can honor the Dupecatcher Rules and create records accordingly within the Apex Trigger and also you'll just a single Apex Trigger and this one will reside on the Case object(I honestly don't like to 'number' Triggers since by practice you should be having only one per sobject but that's a different story ).
- The logic within the Apex Trigger will query the Database to see if there is a matching Contact within the Database(obviously since you'll not have one if you had, the native Email to Case will have filled it there right away!)
- Then, if not found, it'll create an Contact record.
- Now, it could check if there is an Account though. If not, it'll create an Account and tie the Conact created in step 2 to this Account
- That's it
So in essence, it is all possbile but as you know, you need come considerable Development Effort behind this(
you might need a Developer's help to get it done as there are some background procedures to be carried out while implementing one)!