Maximo

Maximo

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

 View Only
  • 1.  How to insert new MEASUREMENT record when ASSET.RISK is updated using Automation Script

    Posted 26 days ago
    Hi ,
     
    I'm working on a requirement where I need to insert a new row into the MEASUREMENT table whenever the RISK field is updated in the ASSET application.
     
    Objective:
     
    When ASSET.RISK is updated, I want to:
     
    Compare ASSETNUM from the ASSET table and the MEASUREPOINT table.
     
    For all matching MEASUREPOINTs (MEASUREPOINT.ASSETNUM = ASSET.ASSETNUM),
     
    Insert a new MEASUREMENT record with:
     
    MEASUREMENT.MEASUREMENTVALUE = ASSET.RISK
     
    MEASUREMENT.MEASUREDATE = system date
     
     
    What I Tried:
     
    I created an Automation Script with an Object Launch Point on the ASSET object, triggered on Update, with a condition:
     
    risk != old.risk
     
    In the script, I:
     
    Queried the MEASUREPOINT MboSet using mbo.getMboSet(...)
     
    Then attempted to add a new MEASUREMENT row
     
     
    I keep getting the error:
     
    BMXAA8334E – The Object Path field requires a value.
     
    I've tried both:
     
    mp.getMboSet("MEASUREMENT")
     
    mbo.getMboSet("MEASUREMENT", "...")
     
     
     
     
    Can someone please help me with:
     
    A working example of the automation script?
     
    Proper way to insert into the MEASUREMENT table when working from ASSET context?


    ------------------------------
    Sangaiah Nimmala
    ------------------------------


  • 2.  RE: How to insert new MEASUREMENT record when ASSET.RISK is updated using Automation Script

    Posted 25 days ago

    Hi Sangaiah,

    You can use either an Object Launch Point, but if i understand the requirement correctly, you can also use an Attribute Launch Point, on ASSET.Risk field.

    The Measurement mboSet can be read either like:

    measSet = MXServer.getMXServer().getMboSet("MEASUREMENT", mbo.getUserInfo())

    or:

    measSet = mbo.getMboSet("MEASUREMENTS") --> name of the relationship to the MEASUREMENT object to be used

    Afterwards add the entry and set the values:
    newMeas = measSet.add()

    newMeas.setValue("fieldName1", value1)

    newMeas.setValue("fieldName2", value2)

    All the required fields in the MEASUREMENT table need to be set accordingly.

    You might need to save the set as well:

    measSet.save()

    Hope this helps.



    ------------------------------
    Liliana Malaescu
    Naviam (formerly known as ZNAPZ)
    Senior Maximo Technical Consultant
    Romania
    ------------------------------



  • 3.  RE: How to insert new MEASUREMENT record when ASSET.RISK is updated using Automation Script

    Posted 25 days ago

    Hi Liliana Malaescu,

    Thanks a lot for quick response let me try from my end and get back to you.

    With Regards

    Sangaiah Nimmala



    ------------------------------
    Sangaiah Nimmala
    ------------------------------



  • 4.  RE: How to insert new MEASUREMENT record when ASSET.RISK is updated using Automation Script

    Posted 22 days ago

    You should use the METERDATA object to create meter readings that would insert records into the MEASUREMENT table for GAUGE or CHARACTERISTIC meters. Maybe something like:

    if mbo.isModified('RISK'):
        meterDataSet = None
        try:
            meterDataSet = MXServer.getMXServer().getMboSet('METERDATA', mbo.getUserInfo())
            
            meterData = meterDataSet.add()
            meterData.setValue('ASSETNUM', mbo.getString('ASSETNUM'))
            meterData.setValue('SITEID', mbo.getString('SITEID'))
            meterData.setValue('METERNAME', 'RISK') # This should be set to whatever the meter name is you are using
            meterData.setValue('NEWREADING', mbo.getString('RISK'))
            meterData.setValue('NEWREADINGDATE', MXServer.getMXServer().getDate())
            meterData.setValue('INSPECTOR', mbo.getUserInfo().getPersonId())
            
            meterDataSet.save()
        finally:
            if meterDataSet:
                meterDataSet.cleanup()
                meterDataSet.close()
    

    I haven't tested this - as a non-persistent object, you might need to use setup() and execute() in place of add() and save(). Also, the isModified() check at the front may or may not be sufficient.

    Hope this helps,



    ------------------------------
    Alex Walter
    CIO
    A3J Group
    Tampa FL
    ------------------------------



  • 5.  RE: How to insert new MEASUREMENT record when ASSET.RISK is updated using Automation Script

    Posted 22 days ago

    Hi Alex,

    Thanks for the response. Let me give a try..



    ------------------------------
    Sangaiah Nimmala
    ------------------------------