Maximo

Maximo

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

 View Only
  • 1.  Automation Script Maximo 7.6.1.2 - Object Launch Point Script "saved"

    Posted Tue May 16, 2023 09:28 AM

    Helo all of you,

    I created an automation script as follow:

    - Object Launch Point = AMSVACTRANS
    - Events = Save ( Add, Update)
    - AMSVACTRANS object has a relationship with another object called AMSTIMECARD through a named relationship = VACTIMESHEET.

    So, the current mbo is AMSVACTRANS and I need to search for a record on VACTIMESHEET which is the zzempoyeeno.

    I wrote the following to search:

    mTS = mbo.getMboSet("VACTIMESHEET")
    mTS.setWhere(CLOCK_IN"+'mVacstart')
    if mTS.isNull("CLOCK_IN"):
    else
      ' not exists , add new record
    mVacstart = mbo.getDate("VACATION_STAT")  && this is mapped to CLOCK_IN , on AMSTIMECARD
    mVacend = mbo.getDate("VACATION_END")    && this is mapped to CLOCK_OUT , on AMSTIMECARD
    mTmesheet =    mTS.add()
    mTimesheet.setValue("CLOCK_IN",mVacstart)
    mTimesheet.setValue("CLOCK_OUT",mVacedn)

    then I got error message CLOCK_IN does not exist !
    Whhile "CLOCK_IN" is an attribute on AMSTIMECARD ??
    Any help to find records through the relationship ?
    Thanks


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

    #Maximo
    #MaximoIntegrationandScripting


  • 2.  RE: Automation Script Maximo 7.6.1.2 - Object Launch Point Script "saved"

    Posted Wed May 17, 2023 01:38 AM
    Edited by System Test Tue August 22, 2023 04:37 PM

    Hi Mohammad, 

    Try below:

    mTS = mbo.getMboSet("VACTIMESHEET")
    mTS.setWhere("CLOCK_IN='"+mVacstart+"'")
    mTS.reset()
    if not (mTS.isEmpty()):
     mTSmbo=mTS.getMbo(0); #I am using getMbo(0) assuming it will return only 1 record. If it returns multiple, you will have to loop through using while loop
     if mTSmbo.isNull("CLOCK_IN"):
      #do your logic
     else:
      #do your logic
      mVacstart = mbo.getDate("VACATION_STAT")  #&& this is mapped to CLOCK_IN , on AMSTIMECARD
      mVacend = mbo.getDate("VACATION_END")    #&& this is mapped to CLOCK_OUT , on AMSTIMECARD
      mTmesheet =    mTS.add()
      mTmesheet.setValue("CLOCK_IN",mVacstart)
      mTmesheet.setValue("CLOCK_OUT",mVacend)



    ------------------------------
    Suhas Joshi
    ------------------------------



  • 3.  RE: Automation Script Maximo 7.6.1.2 - Object Launch Point Script "saved"

    Posted Wed May 17, 2023 03:27 AM
    Hi Suhas,
    Thanks for your help
    I wrote what you did as follows :
    ٢٠٢٣٠٥١٧_٠٩٥٨٠٤.jpg
    .
    and I got the following error:
    Screenshot_٢٠٢٣٠٥١٧_١٠١١١٤_Gallery.jpg





  • 4.  RE: Automation Script Maximo 7.6.1.2 - Object Launch Point Script "saved"

    Posted Wed May 17, 2023 08:14 AM

    Hi Mohammad,
    I think the error prompt related to the setWhere. Since the mEmpno is a variable, it shouldn't be in the quote ''.

    Try instead:

    mTS.setWhere (" ZZEMPLOYEENO= '" +mEmpno+ "'")



    ------------------------------
    Thi Minh Man Nguyen
    ------------------------------



  • 5.  RE: Automation Script Maximo 7.6.1.2 - Object Launch Point Script "saved"

    Posted Sun May 21, 2023 01:27 PM

    Thanks to all,

    it works wit me as:
    mTS.setWhere (" ZZEMPLOYEENO= " + mEmpno)



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