You need to sign in to do that
Don't have an account?
Working with upsertion results
Ok so lets say i do something like this ...
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_upsert.htm
I then have an upsert result array:
UpsertResult[] results = binding.Upsert(sObject[], externalIdField);
...
So lets assume i have some errors and I want to identify what data caused the problem, I want to pull the field values from the sObject in question and look at them ....
Now what ...
Seemingly all I have is a list of fields (literally as a string, this would be much better if it was a field array) a message, and a status code.
There must be more available than this surely?
Ok I did some digging and found what the thought pattern is here ...
The documentation here reads :
The upsert call returns an array of UpsertResult objects. Each element in the array corresponds to the sObject[] array passed as the sObjects parameter in the upsert() call. For example, the object returned in the first index in the UpsertResult array matches the object specified in the first index of the sObject[] array.
Which suggests using a for loop and using the index to track the position from both arrays to match a result to the original sObject used in the call.
This is atypical behaviour but does save a lot of bandwidth so I can see the logic behind it.
I'm actually starting to get there with my Salesforce'ism's now :smileyvery-happy:
Hope this helps others.
All Answers
The fields property on Error is an array. but specifically, what more would you like to see ?
I was hoping to get my hands on the External ID i had to pass in the original call.
I'm guessing it works like this for everyone else too but here's the general flow of events for me ...
1. Pull data from local database
2. Build sObject array
3. Make upsert call using the name of my id field as the required param "External ID"
From here, if I get an error I want to be able to link the error to the record from the source data table to the error.
The problem I have that is say the error reads something like "duplicate external id" how do I identify which of the rows in the duplicate set raised the error, I'm guessing it would be both in that situation but other errors would be more specific to a single row with that unique id.
I guess I was hoping that somewhere in the UpsertResult object would be the original sObject used to make the call but I can't see it anywhere ...
Am I having a dumb 5 minutes again?
Ok I did some digging and found what the thought pattern is here ...
The documentation here reads :
The upsert call returns an array of UpsertResult objects. Each element in the array corresponds to the sObject[] array passed as the sObjects parameter in the upsert() call. For example, the object returned in the first index in the UpsertResult array matches the object specified in the first index of the sObject[] array.
Which suggests using a for loop and using the index to track the position from both arrays to match a result to the original sObject used in the call.
This is atypical behaviour but does save a lot of bandwidth so I can see the logic behind it.
I'm actually starting to get there with my Salesforce'ism's now :smileyvery-happy:
Hope this helps others.