+ Start a Discussion

retrieve - bad id - any recourse?

Hello. I am writing some replication procedures. Essentially I have a database with Company records - each of which corresponds to an Account. The Company holds the Salesforce ID for sync purposes. The replication code queries all Companies that have been updated in a given timeframe, then calls retrieve() with the Account IDs. However if one of the IDs is not valid for whatever reason, this method throws an exception.

I would prefer it to work like the update() method - where if any of the individual processes had errors, those errors are returned in the response array. Then I can walk through the array and handle each success/failure individually.

Is there any way to do this with the retrieve method? Do I want to use query() instead?


Hi cmarkiewicz,

I don't get an exception when I test this.  I get an array of SObjects back.  My test was to retrieve account ids using a query, delete one of the accounts, then retrieve the accounts using the original list of ids.  The one that was deleted comes back as a null in the array of sobjects.



Hello and thanks for the reply.

The ID that I sent was 'x' (well, new ID("x")).

idArray[0] = new ID("x");
SObject[] sObjects = binding.retrieve(fieldString, "Contact", idArray);

results in:
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server
faultString: null: bad id x

bad id x

Obviously I know that 'x' is not a valid ID, but the issue is that I cannot lock others out of the SF_ID field in the database, so this value could conceivable be changed to an invalid ID.


Hi markiewicz,

You may need to pre-process your ids for validation then.  All objects have a defined prefix on the id based on the object type.  For instance, all contacts start with 003.  The ids should be 18 characters in length and are a combination of letters and numbers, no special characters.

You can determine the prefix by calling the describeSobject on the type that you are update/creating to validate the id prefix.

Hope this helps.