Maximo

 View Only
  • 1.  Using variables in setWhere within automation script

    Posted Wed May 24, 2023 05:45 AM

    Hello,

    mTS = mbo.getMboSet("VACTIMESHEET")
    mVacstart = mbo.getDate("VACATION_START")
    mEmpno = mbo.getString("ZZEMPLOYEENO")

    I need to have setWere statement to search for a record in mTS object using the following conditions:

    - TS_DATE = mVacstart
    - ZZEMPLOYEENO = mEmpno

    any help will be much appriciated



    ------------------------------
    mohammad moula
    ------------------------------

    #Maximo
    #MaximoIntegrationandScripting


  • 2.  RE: Using variables in setWhere within automation script

    Posted Wed May 24, 2023 03:25 PM

    mTS = mbo.getMboSet("VACTIMESHEET")
    mVacstart = mbo.getDate("VACATION_START")
    mEmpno = mbo.getString("ZZEMPLOYEENO")
    mTS.setWhere("TS_DATE='"+mVacstart+"' and ZZEMPLOYEENO='"+mEmpno+"'")

    Might have to modify the date field based on whether timestamp validation is required or not.



    ------------------------------
    Akshay T
    ------------------------------



  • 3.  RE: Using variables in setWhere within automation script

    Posted Thu May 25, 2023 10:24 AM

    Because you are calling getMboSet() on an instance of psdi.mbo.Mbo (find the JavaDocs here), the string you are passing is expected to be a relationship name -- most likely one you could find on the Relationships tab in Database Configuration for the Object on your Launch Point.

    Given the above, the easiest way to do what you are asking is to use the functionality Maximo provides instead of doing it all yourself. Go to Database Configuration, find the Object used by your script's Launch Point, go to the Relationships tab and add a new Relationship. I assume the Child Object you want is VACTIMESHEET, and you can name the relationship after the Child Object or something more meaningful than the generic table name. For the Where Clause, specify the following.

    ts_date = :vacation_start
    and zzemployeeno = :zzemployeeno


    Note the column names with a colon on the front. You will find those names on the Attributes tab right there in Database Configuration. Maximo will change those to the values from the record.

    Now, you can go back to your script and use the relationship name you provided above in you call to mbo.getMboSet(), and Maximo will use the where clause you provided in Database Configuration for that Relationship.



    ------------------------------
    Blessings,
    Jason Uppenborn
    Sr. Technical Maximo Consultant
    Cohesive
    ------------------------------



  • 4.  RE: Using variables in setWhere within automation script

    Posted Sun May 28, 2023 07:47 PM

    This is how I would do it:

    mTS = mbo.getMboSet("$VACTIMESHEET", "VACTIMESHEET", "TS_DATE = :VACATION_START and ZZEMPLOYEENO = :ZZEMPLOYEENO")

    This version of the getMboSet method allows you to specify the relationship on the fly. The first parameter is the relationship name, therefore needs to be unique. Prefixing it with $ is not required, just a convention used by Maximo itself. The second parameter is the objectname, and the last one is the where clause. Notice that attribute names prefixed with the colon are replaced with the corresponding values from the "mbo" object.



    ------------------------------
    Gabriel Cesario
    Managing Consultant
    IBM
    Melbourne VIC
    ------------------------------