Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only

Python List Comprehension 

11/21/25 04:02 AM

Use Case:

A Maximo 7.6.1.x customer requested to concatenate certain Service Address fields and display them as a single value in a custom field in a Maximo application. The field was also sent over to an external system in an outbound message.

 

Solution:

We updated an existing Automation Script which fired on WORKORDER Save (Object Launch Point). We used the Python List Comprehension technique to efficiently iterate over the Mbo Attributes of our choice (in a list), and then concatenate the values in a string.

The following code snippet illustrates our solution.

 

attributes = ['STADDRUNITNUM', 'STADDRNUMBER', 'STADDRSTREET', 'PLQUADRANT', 'CITY']

servaddress_set = wo_mbo.getMboSet('LOCATION.SERVICEADDRESS')

if not(servaddress_set.isEmpty()):
    servaddress = servaddress_set.moveFirst()

    if servaddress:
        valueDataList = servaddress.getMboValueData(attributes)
        wosa_formatted_address = ' '.join([str(x.getData()) for x in valueDataList])

 

Here is a brief explanation of the code snippet above:

  • We define the following Service Address fields in a list in Python:
    • STADDRUNITNUM
    • STADDRNUMBER
    • STADDRSTREET
    • PLQUADRANT
    • CITY
  • We call the Java method mbo.getMboValueData(attributes) to get a Value Data List object, which contains the attribute details (i.e. column names, data values).
  • We use Python List Comprehension to iterate over the Value Data List object and call the getData() method to retrieve the column data values.
  • The values are then concatenated by single spaces using the Python join() method.

 

Hope my fellow Maximo developers find this useful. 

Statistics
0 Favorited
25 Views
0 Files
0 Shares
0 Downloads