You need to sign in to do that
Don't have an account?
Blob
Deleting a missing id returns INVALID_CROSS_REFERENCE_KEY
I have a case where I'm deleting OpportunityLineItem, PricebookEntry, and a Product2 instances that are related to each other. I try to delete them in one call to the delete API with the ids in the above mentioned order.
The OpportunityLineItem is successfully deleted on the first try.
The PricebookEntry was removed, but returned as unsuccessful in the DeleteResult.
On the second delete try with only the PricebookEntry (already deleted) and Product2 ids the Product2 id is successfully deleted, but the PricebookEntry returns a INVALID_CROSS_REFERENCE_KEY.
Why is the PricebookEntry DeleteResult return unsuccessful in the first attempt?
Why is it that when I try to delete an already missing id that the DeleteResult is unsuccessful?
It seems to me that if the id is not there it does not need to be removed anylonger and the delete can return a success.
I used SForce Explorer to determine that the id was in fact removed.
The OpportunityLineItem is successfully deleted on the first try.
The PricebookEntry was removed, but returned as unsuccessful in the DeleteResult.
On the second delete try with only the PricebookEntry (already deleted) and Product2 ids the Product2 id is successfully deleted, but the PricebookEntry returns a INVALID_CROSS_REFERENCE_KEY.
Why is the PricebookEntry DeleteResult return unsuccessful in the first attempt?
Why is it that when I try to delete an already missing id that the DeleteResult is unsuccessful?
It seems to me that if the id is not there it does not need to be removed anylonger and the delete can return a success.
I used SForce Explorer to determine that the id was in fact removed.
I don't understand why the delete needs to throw an error if the id to delete does not exist. If the id is not there then the job is already done and the delete should be successful.
- Peter
What did you mean with in 7.0 validation was tightened up?
- Peter
2. The next time I try to delete the remaining id that had the unsuccessful result and it returns the same error. This is in effect trying to remove an id that does not exist and returns the same error as the first time. I think this is a bug also, but as you said this is no longer the case in 7.0 and we will have to work around it.
The bug in 1 is the cause of the situation in 2. I think that the delete method in 7.0 needs to be reviewed again. Please consider returning a success if somebody tries to delete an already deleted id.
- Peter