3

Below is the Result of the Bulk API job(batch) I submitted :

<?xml version="1.0" encoding="UTF-8"?>
<results xmlns="http://www.force.com/2009/06/asyncapi/dataload">
    <result>
        <errors>
            <fields>MailingStateCode</fields>
            <message>A country/territory must be specified before specifying a state value for field: Mailing State/Province Code</message>
            <statusCode>FIELD_INTEGRITY_EXCEPTION</statusCode>
        </errors>
        <success>false</success>
        <created>true</created>
    </result>
</results>

If there is a clear error with the state code, why is it still creating the record (value true for created element in the response)? What am I missing here?

Because the value for created element is true in the response, I tried to find the record in the system but I don't see.

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_upsert_upsertresult.htm -- I have gone through this link but still not clear on how to interpret the above result.

Note: I am sending only one record for the whole Bulk Job and doing this through ETL tool.

2

The created attribute simply tells you if the record was chosen for insert (created is true) or update (created is false). The success attribute tells you if the operation actually succeeded.

Here's a matrix that explains this:

                | created = true | created = false |
----------------+----------------+-----------------+
success = true  |    inserted    |     updated     |
----------------+----------------+-----------------+
success = false |     error      |      error      |
----------------+----------------+-----------------+

I feel that this is a rather clumsy name choice, as created should really be something like operation with the two choices of insert or update.

All you need to remember is that if success is false, no record has been created or updated. The created attribute simply tells you which DML mode the system chose for that record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.