IDM

Understand object and relationship field updates

There are four ways to create a relationship between two objects. For example, suppose these two objects are called planet and moon. To add a new moon to a planet, there are four choices:

This table illustrates the relationship modifications on fields within a planet object or a moon object versus the relationship modifications and endpoints for POST on either a planet object’s edge or a moon object’s edge.
Request type Request example

PATCH-on-planet or PUT-on-planet

PATCH managed/planet/saturn
[{ "operation" : "add", "field" : "/moons/-", "value" : { "_ref" : "managed/moon/titan" } }]
(or PUT managed/planet/saturn with fully-updated moons array)

POST-on-planet-edge

POST managed/planet/saturn/moons?_action=create
{ "_ref" : "managed/moon/titan" }

POST-on-moon-edge

POST managed/moon/titan/planet?_action=create
{ "_ref" : "managed/planet/saturn" }

PATCH-on-moon or PUT-on-moon

PATCH managed/moon/titan
[{ "operation" : "add", "field" : "/planet/-", "value" : { "_ref" : "managed/planet/saturn" } }]
(or PUT managed/moon/titan with fully-updated planets array)

In each case, the behavior of the script invocation differs depending on the configuration. The following table shows the differences between request types and script implementations:

Request types and planet script invocations
Request Type planet: field policy planet: onValidate planet: onUpdate

PATCH-on-planet or PUT-on-planet

Yes

Yes

Yes [1]

POST-on-planet-edge

Not invoked

Not invoked

Not invoked [2]

Request types and moon script invocations
Request Type moon: field policy moon: onValidate moon: onUpdate

POST-on-moon-edge

Not invoked

Not invoked

Not invoked

PATCH-on-moon or PUT-on-moon

Yes

Yes

Yes [3]

Relationship derived virtual property (RDVP) calculations

RDVP calculations depend on the specific request type and the notification settings for relationships between objects.

  • For PATCH-on-planet or PUT-on-planet:

    • RDVP recalculations on the moon object depend on notification settings. If a recalculation is triggered on moon, its field policy, onValidate, and onUpdate scripts are invoked.

  • For POST-on-planet-edge and POST-on-moon-edge:

    • RDVP calculation information is yet to be determined.

  • For PATCH-on-moon or PUT-on-moon:

    • RDVP recalculations on the planet object depend on notification settings. If a recalculation is triggered on planet, its field policy, onValidate, and onUpdate scripts are invoked.


1. The object state doesn’t show a new relationship because it hasn’t been persisted. However, postUpdate and postCreate script hooks do have the new and old relationship states available.
2. The object state doesn’t show a new relationship because it hasn’t been persisted.
3. The object state doesn’t show a new relationship because it hasn’t been persisted. However, postUpdate and postCreate script hooks do have the new and old relationship states available.