0

I am working in Guidewire PolicyCenter V9, I have an array of policies that I am trying to store in the Person entity via an extension of the original entity.

I have attempted to create an array on the Person.etx but cannot establish how to store the array of policies and link it to this entity.

2 Answers2

5

It's most likely ill-advised to create such an array as it will denormalize the relationship between Contact and PolicyPeriod, which already exists. This will not only represent duplicative data in the database, it will have the problem of requiring maintenance, and possibly getting out of synch with the existing relationship present in the database.

A virtual property is likely a better solution to this problem, as it doesn't possibly introduce database inconsistencies and doesn't denormalize the database further.

I'm assuming the requirement to return PolicyPeriods rather than Policies as these are the typical unit-of-work for Policy transactions, and the entity which contains Policy Number, but if this isn't what you're after, you'd just replace elt.Branch with elt.Branch.Policy, and change the return type and name of the virtual property.

package com.acme.enhancements

uses gw.api.database.Query
uses gw.api.database.Relop

enhancement PersonEnhancement : entity.Person {
 
  property get PolicyPeriods() : Set<PolicyPeriod> {
    var policiesImPresentOn = Query.make(PolicyContactRole).compare(PolicyContactRole#ContactDenorm, Relop.Equals,this).select().toList()
    var setToReturn = new HashSet<PolicyPeriod>()
    policiesImPresentOn.each(\elt -> setToReturn.add(elt.Branch))
    return setToReturn
  }
}
Domenick Doran
  • 261
  • 1
  • 7
0

If at all you want to persist the data, then here is a way:

As there is no such DB column to store the array of objects and hence Guidewire follows approach of having a reverse foreign key. Like if we have an array element in the entity A to entity B, then there should a reverse foreign key pointing back to Entity A.

And in your example, create array(of Policy) column in Person entity and create a foreign key in Policy pointing back to Person entity. By doing so, every row in policy tells to which person it is associated to. And if you want to get list of policies belonging to particular person, then you have to query Policy entity retrieving all rows in it associated with ID of that person.

Sergiy Ostrovsky
  • 2,372
  • 2
  • 16
  • 23