PingOne Advanced Identity Cloud

Relationship update methods and their effects

When you create a relationship between two objects, the API request you use determines which scripts are triggered and when derived properties are recalculated.

The following sections explain the effects of the four different ways you can update a relationship. For example, to create a relationship between a planet object and a moon object, you can either update the object directly or POST to the relationship endpoint. The method you choose has important implications for server-side processing.

Method 1: Update the source object directly

You can create a relationship by sending a PATCH or PUT request to the "source" of the relationship. In this example, the planet object is the source.

Request
PATCH managed/planet/saturn
[{ "operation" : "add", "field" : "/moons/-", "value" : { "_ref" : "managed/moon/titan" } }]

// Alternatively, a PUT request with the fully-updated moons array.

Effects

  • Scripts on the source object (planet): The field policy, onValidate, and onUpdate scripts are invoked.[1]

  • Scripts on the target object (moon): Scripts aren’t invoked.

  • RDVP calculations: Recalculations for relationship derived virtual properties (RDVPs) on the target object (moon) depend on notification settings. If a recalculation is triggered, the moon object’s field policy, onValidate, and onUpdate scripts are then invoked.

Method 2: Update the source object’s relationship endpoint

You can also create the relationship by sending a POST request to the relationship endpoint on the source object.

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

Effects

  • Scripts on the source object (planet): Scripts aren’t invoked.

  • Scripts on the target object (moon): Scripts aren’t invoked.

  • RDVP calculations: RDVP calculations aren’t triggered on either object.

Method 3: Update the target object’s relationship endpoint

Similarly, you can POST to the relationship endpoint on the target object.

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

Effects

  • Scripts on the source object (planet): Scripts aren’t invoked.

  • Scripts on the target object (moon): Scripts aren’t invoked.

  • RDVP calculations: RDVP calculations aren’t triggered on either object.

Method 4: Update the target object directly

Finally, you can create the relationship by sending a PATCH or PUT request to the "target" of the relationship.

Request
PATCH managed/moon/titan
[{ "operation" : "add", "field" : "/planet/-", "value" : { "_ref" : "managed/planet/saturn" } }]

// Alternatively, a PUT request with the fully-updated planets array.

Effects

  • Scripts on the source object (planet): Scripts aren’t invoked.

  • Scripts on the target object (moon): The field policy, onValidate, and onUpdate scripts are invoked.[1]

  • RDVP calculations: Recalculations for RDVPs on the source object (planet) depend on notification settings. If a recalculation is triggered, the planet object’s field policy, onValidate, and onUpdate scripts are then invoked.


1. The object state in these scripts doesn’t show the new relationship because it hasn’t been persisted yet. However, `postUpdate` and `postCreate` script hooks do have the new and old relationship states available.