Communication between instances (Link)

Sending entities between instances requires:

  1. Two One ERP instances;

  2. The entity to be sent must have the same structure on both instances;

  3. The entity on the sender and on the receiver must both have a property named uuid of type string.

Sending entities without relationships

Sending entities with identical property sets

Sending is done using the following code:

workflow SendEntity; method main() { // Create an entity record var c as ENTITY car; c.name = "test"; PUT c; var policy as transportpolicy; // This example sends created entity record to instance "demo.oneerp.ro" link->send("demo.oneerp.ro", "car", c.key, policy); }

The full API can be found here.

Sending entities with different structures

By default One ERP Link assumes that the entities on both the receiver and the sender have the same structure. Depending on your use case this might not always be true, here comes into play the transport policy. 

There are two possible cases:

Case 1 - The property exists on the sender and doesn't exist on the receiver

Let's assume the following use case, the entity "car" with properties on the sender and receiver as described in the following table:

Property name

Type on sender

Type on receiver

Property name

Type on sender

Type on receiver

name

string

string

year_of_manufacturing

int

int

color

string

n/a

Sending the entity car from the sender to the receiver, as described in the previous example, will yield a schema validation exception because the "color" property is missing on the receiver. The solution is to set the excludePropertyNames property on the transport policy with value "color", this will instruct One ERP Link to send the entity even if the "color" property is missing on the receiver.

workflow SendEntity; method main() { // Create an entity record var c as ENTITY car; c.name = "test"; c.year_of_manufacturin = 2018; c.color = "red"; PUT c; var policy as transportpolicy; // This will make the color property optional on the receiver policy.ignoreMissingProperties = true; // This example sends created entity record to instance "demo.oneerp.ro" link->send("demo.oneerp.ro", "car", c.key, policy); }

Case 2 - The property doesn't exist on the sender and exists on the receiver

Sending entities with relationships

Sending entities that have relationships with other entities 

Interpreting error messages