function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
aditya rawataditya rawat 

Missing ExternalId in external api for creating custom adapter

The ability to build custom lightning connect adapter is one the most exciting features in recent release, however I am trying to find a solution to able to provide externalId for the custom adapter.

You see the api that I had been trying to connect for pulling data has no unique identifier in the resultset, so now I am in a difficult position of not being able to provide ExternalID for building custom adapters.

I had been thinking of being of using integer for loop counter, but that way it wont be an identifier of the record in any way, any thoughts for providing externalId in custom adapters when there in such situation ?

"Each external object has an External ID standard field. Its values uniquely identify each external object record in an organization. When the external object is the parent in an external lookup relationship, the External ID standard field is used to identify the child records.....
The custom adapter’s Apex code must declare the DataSource.Column named ExternalId and provide its values. "


Best Answer chosen by aditya rawat
Agustina GarciaAgustina Garcia
Really good question actually.

Something that comes to my mind. You can create a method that generate random values dependind on some parameters, for instance, and String and a Size values, in order to have MEI-000000 or IEX-41. And this will be your External Id for your records.

Then, the second part, how can you be sure that the generatred doesn't exist? You can create a custom object with a a single Text field where you can store every External Id is autogenerated. Before assigning it to your external object record, you can check in your object if it is already in used, and if this is true, go ahead and generate a new one.

Hope this helps or inspire you to get another solution.