Search code examples
configurationforeign-keysrelationshipjythonmaximo

Automation script: Get value from related table


I'm trying to break this problem down into manageable parts: Spatial Query.


I want to create an automation script that will put a work order's LatitudeY coordinate in the work order's DESCRIPTION field.

I understand that a work order's coordinates are not stored in the WORKORDER table; they're stored in the WOSERVICEADDRESS table.

Therefore, I believe the script needs to reference a relationship in the Database Configuration application that will point to the related table.

How can I do this?

(Maximo 7.6.1.1)


Solution

  • You can get the related Mbo and get the values from the related Mbo and use it as shown in the below code. By getting the related Mbo you can also alter it's attributes.

    from psdi.mbo import MboConstants
    serviceAddressSet = mbo.getMboSet("SERVICEADDRESS")
    if(serviceAddressSet.count() > 0):
        serviceAddressMbo = serviceAddressSet.moveFirst()
        latitudeY = serviceAddressMbo.getString("LATITUDEY")
        longitudeX = serviceAddressMbo.getString("LONGITUDEX")
        mbo.setValue("DESCRIPTION","%s, %s" % (longitudeX, latitudeY),MboConstants.NOACCESSCHECK)
    serviceAddressSet.close()