1

I am trying to run a batch apex to update a list of leads, i get this error

'INVALID_CROSS_REFERENCE_KEY, invalid cross reference id:'

only for few of the apex jobs, the other jobs of the batch are shown as success.

There is no other clue as to what is causing this error.I browsed through the whole log, and there is no single exception recorded in the debug log.

Is it specific to the sandbox or the Lead object?

  • Could your batch be trying to update a converted lead? – Girbot Apr 27 '15 at 12:57
  • No, it just updates : OwnerId, Status and 2 custom fields. – Shalini SF Apr 27 '15 at 22:58
  • I tried to print a debug statement after the update Database.SaveResult[] srList = Database.update(leadsList, false); – Shalini SF Apr 28 '15 at 0:16
  • Assuming the custom fields aren't lookup fields and you don't have any workflows or triggers on the Lead that update related objects, then the issue would be the ownerId. Any chance that you are updating the ownerId to an inactive user/queue, a null ownerId, or an sobject that is not a valid owner type? – cropredy Apr 28 '15 at 17:51
  • I am updating the owner Id to an active Queue, also if fails only for few jobs. Any idea where to debug this issue from? where to look for the exception?As already commented, i am not able to find anything wrong with the debug logs except for the title which says 'Update failed due to INVALID_CROSS_REFERENCE_KEY, invalid cross reference id:' – Shalini SF Apr 29 '15 at 1:23

Your Answer

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

Browse other questions tagged or ask your own question.