Saving and reading an order with origin information

Order Service contains APIs that you can use to configure, save (or index), and read an order summary against a unique set of attributes, such as order number, document type and enterprise code, or order identifier. However, when multiple Sterling Order Management System Software instances are integrated with one Order Service instance, you must also supply the origin id to uniquely identify an order while saving order summary data in Order Service. The origin identifier indicates a Sterling Order Management System Software instance where the order was originally created.

In addition to the origin identifier, you can also pass the Sterling Order Management System Software deployment URL, location, or any instance details while saving order summary data in Order Service. While searching for orders, the additional information on every hit helps you to locate Sterling Order Management System Software instances where an order was originally created and redirect to that location for complete details of the order.

Important: To refer to the information about origin, see Configuring origin attributes.

Configuring origin information

Origin contains the information about where the order was originally created, such as Sterling Order Management System Software instance identifier and any additional details, such as the deployment URL, which is useful in an order search response. The order save APIs understands the instance identifier and are represented by the origin.id field. But if there are other origin fields configured on Sterling Order Management System Software, you must add them to the order index by using the createSearchIndex API, while creating the index. However, if an index is already created, you can use the updateSearchIndex API to update the origin mappings before you send orders to Order Service.

Refer to the following sample code for configuring and mapping the additional fields, in this case, URL, to the origin field for the createSearchIndex or updateSearchIndex API:

{ 
 "index":{
  "id":"order",
  "mappings":{
   "Amount":
   { "type": "keyword", "index": true, "store": true},
   "BillToID":
   { "type": "keyword", "index": true, "store": true}
  },
  "originMappings":{
   "url":
   { "type": "keyword", "index": true, "store": true}
  }
 }
}

Saving an order with origin information

Refer to the following example of saving an order with the origin information.

{
 "order":
 {
  "orderId":{
  "id":"001",
  "orderNo":"ORD001",
  "documentType":"DOC001",
  "enterpriseCode":"ENT001",
  "origin":{
   "id":"OriginA",
   "url":"OriginAUrl"
   }
  },
  "summary":{
   "BillToID":"BillToID1",
   "Amount":"910011"
  }
 }
}

If origin information is shared along with the identifier, the document identifier for an order document is formed as a concatenation of "'origin.id'+'id'". In the example, the order summary information is saved in Elasticsearch with the id "OriginA001".

Reading an order with origin information

Refer to the following example of reading an order with origin information for an order.


{ 
 "orderID": {
  "id": "001",
  "origin":{
   "id": "OriginA"
   }
 }
}

The origin information is saved as _orderId.origin in the index. Therefore, when any order origin fields are needed, use additionalData option and specify the exact field name in the _orderId.origin.<origin attribute name> format.

For example, to get the origin URL, use the additionalData option, as follows, for the readOrderSummary and searchOrder APIs.

query readOrderSummary($orderId:OrderIdFetchInput!)
{
 readOrderSummary(orderId:$orderId)
 {
  id,
  orderId
  {
   orderNo,
   enterpriseCode,
   documentType,
   id
  }
  additionalData(field["_orderId.origin.url"]),
  version
  status
 }
}

For more information about archiving and retrieving order with origin information, see Archiving and retrieving an order with origin information.