Updater case 2: Root and resolved value have a common ancestor

In some cases, the root entity and the resolved value have a common ancestor. This typically occurs when both entities are part of a graph, such as the claim graph or policy graph, and you want to ensure that both entities share the same ancestor. (In other words, both entities are owned by the same claim or the same policy.)

For example, suppose underwriters periodically upload documents to a customer portal. To manage this work, you have implemented "Upload to portal" activities. You want each activity to references the document to upload. In the Activity entity, you have created a DocumentToUpload_Ext field that points to the Document entity. However, you do not want to let a caller application associate any document in PolicyCenter with a given activity. Both the activity and the document must belong to the same account. In other words, they must have a common ancestor.

When the two entities share a common ancestor, you can use the KeyableBeanJsonValueResolver (gw.rest.core.pl.framework.v1.refs.KeyableBeanJsonValueResolver). However you must add two additional fields to the updater:

  • resolvedValueToAncestorPath - This specifies the path that traverses from the foreign key entity to the common ancestor.
    • The path starts with the resolvedValue symbol, which represents the foreign key entity.
    • The path ends with the common ancestor, which may be any number of levels away.
    • For example, resolvedValue.Account.
  • rootToAncestorPath - This specifies the path that traverses from the root entity to the common ancestor.
    • The path starts with the name of the root resource.
    • The path ends with the common ancestor, which may be any number of levels away.
    • For example, Activity.Account.

For example, the updater for the "Upload to portal" activity example would be:

"updaters": {
  "Activity": {
    "properties": {
      "documentToUpload_Ext": {
        "path": "Activity.DocumentToUpload_Ext",
        "valueResolver": {
          "typeName": "gw.rest.core.pl.framework.v1.refs.KeyableBeanJsonValueResolver"
          "resolvedValueToAncestorPath": "resolvedValue.Account",
          "rootToAncestorPath": "Activity.Account"
        }
      }
    }
  }
}

If you specify resolvedValueToAncestorPath but do not specify rootToAncestorPath, then the root of the updater will be used as the ancestor to match.

Cloud API also provides value resolvers for specific base configuration entities. These resolvers may automatically implement common ancestor validation.

You can find a list of entity-specific value resolvers in Studio by executing a Navigate > File command (CTRL + SHIFT + N) and entering "valueresolver". Be aware that the entity-specific value resolvers may have special behaviors to enable common Cloud API use cases. These behaviors may not be appropriate for an updater to a custom foreign key. Whenever you use a entity-specific value resolver, Guidewire recommends testing the associated PATCH and POST behaviors thoroughly.

Validation when root and resolved value ancestors do not match

For this type of updater, if a caller application attempts to set a foreign key field to an object that does not share a common ancestor, an error similar to the following is returned:

data.attributes.documentToUpload_Ext.id - The id 'cc:Suyx2KNC82n2MiAXGml8M' is not
a valid 'Document'"