Create a custom object

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

In a beanshell rule using hashmap coding beanshell rules using hashmap association, between country code - area - specific value
It’s not a suitable approach because there can be evolution and could be reusable values, is there a sample example do that using custom object?

Thanks

Yeap you can do that for example having custom object like this

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE Custom PUBLIC "sailpoint.dtd" "sailpoint.dtd">
<Custom name="Custom Config">
  <Attributes>
    <Map>
      <entry key="Key1" value="Value2"/>
      <entry key="Key2" value="Value2"/>
    </Map>
  </Attributes>
</Custom>

you can just use it in your beanshel that way

Custom custom = context.getObject(Custom.class,"Custom Config");
custom.get("Key1");

If you want to create custom object from rule you can do that also like this

  import sailpoint.object.Custom;

  String customName = "Custom Config";
  Custom custom = new Custom();
  custom.setName(customName);
  custom.put("Key1","Value2");
  custom.put("Key2","Value2");
  
  context.saveObject(custom);
  context.commitTransaction();
  
3 Likes

Hi @massinissa

What was mentioned by @kjakubiak is 100% working and also here you are the Wiki topic in SailPoint Compass as well for your reference:

2 Likes

Custom objects are the correct place to put this information. I have seen developers put data into Configuration object and also seen them embed information inappropriately into TaskDefinition objects.
Regarding your code, my concern is that this is not thread safe, you should lock the object before editing and then unlock after.

Hi Keith,
Save rule is one time execution code. It’s highly unprobable to have simultaneous access to objest you are just creating :slight_smile:

1 Like

Is using Configuration object for this purpose suitable , or custum objects are better ?

you can use custom object , this is best in case if you need to modify something without modifying code .

Configuration and Custom objects are essentially the same. They’re both just abstractions of Java maps (or, more specifically, sailpoint.object.Attributes). You can use them interchangeably. I generally use them as they’re named. Configuration is for stuff like setting up plugins, configuring rule behavior, etc. Custom is for stuff like looking up values by country code.

There is ONE situation where I always prefer Configuration objects: the specific Configuration object SystemConfiguration is cached in memory. You can get it in code using Configuration.getConfiguration(). This can be enormously faster than loading the same objects repeatedly. For certain processes, I prefer putting my config stuff under SystemConfiguration (via a “merge” import) and then using the cached in-memory copy.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.