Maximo

Maximo

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

 View Only
  • 1.  Carrying over AssetMeter Remarks to Measurement table

    Posted Wed August 28, 2024 12:26 PM

    Currently trying to capture the remarks field from the assetmeter table to the measurement table's user defined field.  What would be the best approach for this?  I have dabbled with automation scripting with an object launch point and it seems to copy the field over and this is reflected in the UI, but the data does not commit to the database.



    ------------------------------
    jordan lum
    ------------------------------



  • 2.  RE: Carrying over AssetMeter Remarks to Measurement table

    Posted Thu August 29, 2024 02:23 PM

    Hey Jordan,

    This worked for me as a Run Action Attribute Launch Point (ASSETMETER.REMARKS) script:

    from psdi.mbo import MboConstants
    
    def main():
        # Ensure you're dealing with the expected Mbo type
        if mbo is not None and mbo.isBasedOn("ASSETMETER"):
            # Check if the attribute has been updated/modified
            if mbo.isModified("REMARKS"):
                # Get the updated value from the ASSETMETER object
                remarks = mbo.getString("REMARKS")
    
                # Retrieve the related MboSet (Using MEASUREMENT relationship on ASSETMETER object)
                measurement_set = mbo.getMboSet("MEASUREMENT")
                measurement = measurement_set.moveFirst()
    
                # Loop through each Measurement Mbo in the set
                while measurement is not None:
                    # Update the COMMENTS field in the MEASUREMENT table
                    measurement.setValue("COMMENTS", remarks, MboConstants.NOACCESSCHECK | MboConstants.NOVALIDATION)
    
                    # Move to the next Measurement in the set
                    measurement = measurement_set.moveNext()
    
    main()

    Let me know how you make out.

    Cheers,



    ------------------------------
    Matt F
    ------------------------------