Skip to main content

Set profile values in rules

Contacts, portfolios and securities may have additional data stored into their profile as attributes. These attributes can be get, set or removed in rules using a handy utility called ProfileUtil.

Import

The ProfileUtil and Profile2 needs to be imported into the rule table:

import fi.fasolutions.mod.portfoliomanagement.util.*;
import fi.fasolutions.mod.portfoliomanagement.domain.Profile2

or

fi.fasolutions.mod.portfoliomanagement.util.ProfileUtil,fi.fasolutions.mod.portfoliomanagement.domain.Profile2;

Usage

Get profile attribute

Example of getting a profile attribute of type String from a portfolio

ProfileUtil.getProfileAttribute($p, "<attributeKey>", String.class, services)

Set profile attribute

Example of setting a profile attribute of type String to a portfolio

ProfileUtil.setProfileAttribute($p, "<attributeKey>", "<Attribute value>", services)

If several values need to be set, the first value is set as in the above example, but then the second and following values are set so that the Profile2 object is passed to the method instead of the contact, portfolio or security:

Profile2 profile2 = ProfileUtil.setProfileAttribute($p, "<first attributeKey>", "<First attribute value>", services)
profile2 = ProfileUtil.setProfileAttribute(profile2, "<second attributeKey>", "<Second attribute value>", services)
profile2 = ProfileUtil.setProfileAttribute(profile2, "<third attributeKey>", "<Third attribute value>", services)

Remove profile attribute

Example of removing a profile attribute from a portfolio

ProfileUtil.removeProfileAttribute($p, "<attributeKey>", services)