You need to sign in to do that
Don't have an account?
Delete record 24 hours after creation if a field is empty
Hello everyone,
I am trying to make a simple web shop. I have a custom object Basket (the shopping cart) that holds BasketLineItems (the chosen goods, custom objects as well) and has a field with a lookup for Contact objects (representing the customer). The Basket doesn't need to have the contact field filled in at the point of its creation, but if it doesn't get filled within 24 hours, the Basket record in question should be deleted.
I've searched around and so far, the best way seems to make a Scheduled Apex class and have it run frequently, every hour or so, checking creation times and deleting accordingly, but that means it's possible for a record to exist for more than 24 hours, plus it's a pain and a strain to schedule the job more frequently. Can't I make something that's basically a timebomb and stick it to the record?
There is another option, however this will still require you to write code. What you can try is to create an process builder that will execute an apex code as time dependent action. This code will delete the Basket record if no shopping cart is found. This solution will overcome the limitation that you mentioned in scheduling apex class.
Please use the below link to see how you can execute a apex code from process builder.
https://automationchampion.com/2015/07/09/getting-started-with-process-builder-part-33-call-an-apex-method-from-a-process/
Hope this helps.