How to correctly handle synonym domains in automation script

We all know that Maximo allows the definition of new internal values for synonym domains. A common example is the LOCTYPE domain that defines the allowed values for the LOCATIONS.TYPE field.
If we want to implement a special business logic for the OPERATING type of locations we can write something like this in our automation script.

loctype = mbo.getString("TYPE")
if loctype=="OPERATING":
  # do something....

However, if we define a new alias for the OPERATING type this script will not work as expected because it will not manage automatically the different internal values of the LOCTYPE domain.

The best solution is to use the psdi.mbo.Translate.toInternalString method like this:

from psdi.server import MXServer

loctype = MXServer.getMXServer().getMaximoDD().getTranslator().toInternalString("LOCTYPE", mbo.getString("TYPE"), mbo)
if loctype=="OPERATING":
  # do something....

The toInternalString method will translate the internal value of the LOCATIONS.TYPE field to the corresponding domain external value.

There are two implementations of the toInternalString method that are documented in the Javadoc.

String toInternalString(String listName, String value)
Convert a specified value in the list to an internal MAXIMO value.
String returned is a single value.
Parameters:
listName – The valuelist name (valuelist.listname).  This is not case sensitive.
value – The external value (valuelist.value).  This is case sensitive.
Returns The internal value (valuelist.maxvalue)

 

String toInternalString(String listName, String value, MboRemote mbo)
Convert a specified value in the list to an internal MAXIMO value.
String returned is a single value.
Framework will use the siteid of the passed in MBO if it is site level, or the orgid of the MBO if it is org level to find out the actual values for the specified domain, and use those values for translation. If the siteid and orgid of the MBO is null, all the value records will be considered.
Parameters:
listName – The valuelist name (valuelist.listname).  This is not case sensitive.
value – The external value (valuelist.value).  This is case sensitive.
mbo – the MBO that the translation values are used for or the MBO which the site and org is same with the MBO that the translation is used for.
Returns The internal value (valuelist.maxvalue)

How to correctly handle synonym domains in automation script

3 thoughts on “How to correctly handle synonym domains in automation script

  1. Thanks for the article.

    There is one more implementation:
    String toInternalString(java.lang.String listName, java.lang.String value, java.lang.String siteId, java.lang.String orgId)

    – listName – The valuelist name (valuelist.listname). This is not case sensitive.
    – value – The external value (valuelist.value). This is case sensitive.
    – siteId – site
    – orgId – organization

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top