Skip to content
Territory

Salesforce to ERP

Salesforce → ERP

Salesforce does not push territories or geographies to ERP. There is no webhook and no ERP_Integration_Setting for Territory_Master__c. ERP is the caller. What comes back is the HTTP result of that call.

Territory upsert

PATCH /services/data/v67.0/sobjects/Territory_Master__c/Territory_Code__c/{code} has two success shapes.

A code Salesforce has never seen is HTTP 201:

{
  "id": "a0T000000000003AAA",
  "success": true,
  "errors": [],
  "created": true
}

ERP requires id and then drops it. The local row is marked Synced. There is no Salesforce field on the ERP territory for this id.

A code Salesforce already has is HTTP 204 and an empty body.

HTTP/1.1 204 No Content

ERP reads that as a failure: territory upsert: empty id (status 204). The local syncStatus becomes Failed, and ERP posts the failed Integration Log. The Salesforce row was updated. The next sync sends the same PATCH and gets 204 again.

A validation failure is the Salesforce error array, wrapped only as the text of that error. The ERP sync API answers HTTP 500 internal_error with message internal server error.

Geography create

POST /services/data/v67.0/composite/sobjects answers HTTP 200 with an array, one object per record sent:

[
  {
    "id": "a0G000000000003AAA",
    "success": true,
    "errors": [],
    "created": true
  }
]

allOrNone is false, so Salesforce can create some rows and reject others in the same response. ERP marks the whole batch Failed when any element has success: false. Ids are not stored. A later sync queries Territory_Geography__c by Territory_Code__c and does not send a pair that is already there.

An empty query result means every Pending geography for that territory is sent. A pair that matches Geography_Type__c and Geography_Value__c is left out of the composite body.