An indeterminate number of images will be attached to Lead records. We have a requirement that 5 minutes after the last image is attached, the Lead owner should automatically receive an email.

I've thought of one approach to this: Every time an image is attached to a Lead record, schedule a job to happen 5 minutes later. When the job executes 5 minutes later, check for images uploaded in the last five minutes and/or for more similar pending jobs. If anything is found, do nothing. If nothing is found, send the email.

But I expect this could burn through our async limits pretty quickly (assuming there are a lot of leads and many images are uploaded.

Is there a better way to approach this?


Instead of the scheduled job checking, have the scheduler check when scheduling the job. If a job already exists, abort it. Then, schedule a new one. This gives you an exact five minutes of delay instead of a variable delay between 5 and 10 minutes, and reduces the asynchronous usage accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.