0

I have a SOAP request that sets the lookup fields using the lookup object's external IDs. However, for one particular lookup, I can't guarantee that it will find a matching Salesforce record. If that's the case, I still want it to insert, but insert with the lookup field set to null.

Currently, it will just throw an error saying the lookup value is not found. Is there a way to get around this in the SOAP message?

I'm using XSL transformations via the Oracle Service Bus.

Example:

:Foreign key external ID: 123456 not found for field Order_External_Key__c in entity Order:INVALID_FIELD;

1 Answer 1

1

Basically, no. You need to know the record exists, or create it beforehand. Your best bet would be to upsert the parent records beforehand and/or perform a query to check, thus ensuring that the records exist. This will double the number of API calls you need to use, but you can upsert in batches of 200 at a time, so it shouldn't be a significant problem.

1
  • @MayaTran Lookup validation occurs before triggers. You could create a custom text field and populate that, then have the trigger query/create records (or set null, etc).
    – sfdcfox
    Commented May 6, 2019 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .