+ Start a Discussion

Foreign key external ID not found


we have a oracle and Sf integration through SOA. we have two custom objects called orders and Customer in SF.. Orders will be updated for Every 15 minutes through SOA. also we have a lookup relation from orders to Customer. 

1Question : 

when Orders were updated if there is no customer ID ( we use customer id as forgien key )  found we are getting an error . says Foreign key external ID not found ..  how can i resolve this. 

2Question : 

if i write a trigger to update Customer id with the value i am getting also it asks first name and last name which is not in Salesforce .. so first time insert as unknown and second time upsert the values. , or is there any other way to resolve this?

really apprciate your help


Roman VasetskiyRoman Vasetskiy
1. I have absolutely the same issue once. So, as for now, you have two options to solve this problem
  • Integrate Customers right before orders every time you integrate orders to be sure that parent record (in your case - customer) exists for every order. This is the most effective solution and the most correct solution. 
  • If, for some reasons, you can't go with previous option, you could write before insert(update) trigger where you should check - if a customer does not exist for an order, then nullify reference field and leave that reference empty. In that case you will have orphaned, but inserted order. 
2. What do you mean "update Customer Id" ? Could you please explain a bit what do you mean? Not sure I understand the question correctly
Nithya S 1Nithya S 1

Hello Roman,
I have a similar issue. But strangely, the value that is returned, is present in Salesforce and yet the error occurs "Foreign key external ID: <ExternalID> not found for field <fieldname> in entity <entityname>

Would you have a solution for this?