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

Create Custom Object Record Upon Case Creation
Hello,
I am having trouble wrapping my head around something. We are setting up a Web-To-Case integration where a Case will be created when an internal system receives an alert. The Case will have an internal identifier field that is also populated on the Case record. All that is fine, however, if multiple alerts occur for Cases with the same internal identifier, I need to create the case via web-to-case, search for any open cases with that internal identifier, add a new custom object record linked to the existing case, and then delete the new case. The end result would be 1 open case per identifier, with potentially multiple custom object records. Can anyone suggest how I can do this with a trigger or some other method?
I am having trouble wrapping my head around something. We are setting up a Web-To-Case integration where a Case will be created when an internal system receives an alert. The Case will have an internal identifier field that is also populated on the Case record. All that is fine, however, if multiple alerts occur for Cases with the same internal identifier, I need to create the case via web-to-case, search for any open cases with that internal identifier, add a new custom object record linked to the existing case, and then delete the new case. The end result would be 1 open case per identifier, with potentially multiple custom object records. Can anyone suggest how I can do this with a trigger or some other method?
Thanks forr your post.
There are several way to achieve this requirement with small tweak
1) If you can make this identifier field unique then new case wll not get created, because of run-time error saying record is already present with same identifier. But with this approach you won't be able to create custom object record.
2) You can create process builder on every case creation which will call flow
Flow will consist
-> Lookup to see if there is any existing record with same identifier
--> Desision if same identifier is present
--> Create custom object record
--> Delete case
Example: https://automationchampion.com/tag/launch-flow-from-process-builder/
https://developingflow.com/2015/07/11/launch-a-flow-using-lightning-process-builder/
https://judisohn.com/2015/04/06/using-salesforce-process-builder-flow-with-opportunity-contact-roles/
3) Create trigger.
Please let me know, if any more information is required.
Please mark this answer as best if reply helped to resolve your quesy.
http://salesforce.stackexchange.com/questions/42124/deleting-records-in-an-after-trigger