I’m trying to delete a Customer record in Business Central/NAV using the SmartConnect SOAP CustomerCard endpoint.
When I run the integration, it fails with the error:
Failed to delete record with Keys ‘Key = XXX’ Key “XXX” is not well formed!
Why do I get this error?
The reason for the error is a mismatch for the data provided for the Key field on this integration.
In this case, using the CustomerCard SOAP endpoint, the only field required to delete the Customer record is the “Key” field.
Notice that the field is “Key” and not “No”.
The No field in Business Central/NAV is a human readable such as “PTR”.
The Key field in Business Central/NAV is a long identifier such as “16;EgAAAAJ7/1AAVABS7;31847521;22;AgedAccReceivableChart1;16;EgAAAAJ7/1AAVABS7;31847520;“
In this case, the error happened because the “No” field was mapped to the “Key” field on that map. Because the Key field wasn’t in the correct format, Business Central gave this error.
There are two solutions:
1. Using the SOAP connector, since we likely do not have the hidden Key field, we can use SmartConnect to look that up for us using a Page Field Lookup.
This lookup type will return the Key for a record if you give it the fields to look up with. Typically this would be the No field but it could be a combination of other fields of No wasn’t available for some reason.
Once the calculation for the Page Field Lookup is created, map this new lookup to the Key field on the entity and group on this field.
2. Using the ODATA connector in SmartConnect 20.18.1.11 and greater, we can also delete records.
In this case, we wouldn’t need to use a lookup. Instead, we just map our field(s) to tell Business Central which fields to match and delete with – No in this case since we have it – and mark the For Delete option.
Example maps for both solutions using SmartConnect 20.18.1.11 are ATTACHED.