0

I get this error while trying to perform deletion using a batch job. I have all access to the object. In my case, Custom obj A is parent and B is the child (One to many). As per the code, when record of obj A is deleted, B obj related records should be deleted. Now, since the scheduled job runs only on Saturday, few of the child records won't exist in the system by the time the job executes the code. This is leading to the issue since the job is trying to record child records that don't exist in the system. How do i solve this?

  • I think we need some clarification. Why don't the child records exist yet when you run the batch job? It sounds like you have some secondary code that creates these child records? Code examples could also be very helpful to understand what is happening. – Kris Goncalves Oct 25 '19 at 13:09
  • I'm not sure why the batch job is having this issue. When the scheduled job is run, are you querying for parent records with isDeleted = true to find all the ones that were deleted that week? If so, are you then querying for all the related child and deleting them? Some more context is needed here as @Kris Goncalves mentioned. – Roti Oct 25 '19 at 17:20
0

Yes, the child records can be deleted manually by users .. so by the time the batch job runs, these records won't be in Salesforce anymore.

|improve this answer|||||
  • is this an answer to your question? or an answer to one of the comments? If the latter; delete this answer and respond in comments to the OP or, better yet, edit the OP – cropredy Oct 26 '19 at 19:47

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.