Maximo Open Forum

 View Only
  • 1.  Automation scripts.

    Posted 05-19-2023 04:48

    Can you tell me the automation script for  opying target start date to actual start date and also populate owner with current user id after approval of workorder. Step by step


    #EverythingMaximo

    ------------------------------
    Gaurav Sharma
    ------------------------------


  • 2.  RE: Automation scripts.

    Posted 05-22-2023 05:03

    mbo.setValue("ACTSTART",mbo.getDate("TARGSTARTDATE"),11L)
    mbo.setValue("OWNER",user,11L)

    Considering USERID and PERSONID are same. Otherwise, get the PERSONID from user variable and set.



    ------------------------------
    Prashant Sharma
    Sedin Technologies
    Connect with me @ https://www.linkedin.com/in/psharmamaximo/

    #IBM Champion 2022
    #IBM Champion 2023
    ------------------------------



  • 3.  RE: Automation scripts.

    Posted 05-22-2023 07:59

    Hi Gaurav,

    Prashant's response is technically correct, but is a little sloppy. He probably was just trying to answer quickly. 

    You should should not just assume that the user and person Id are the same when it is easy to get the person Id from the Mbo's UserInfo class.  You also should not use raw numbers for option flags, but should import the MboConstants class and use them from there.  The value of 11L is probably NOVALIDATION_AND_NOACTION plus NOACCESSCHECK, which is a little weird and probably just a copy / paste error. I have gone ahead and assumed that he meant to ignore read only and retained the NOACCESSCHECK option flag.

    Jython below:

    from psdi.mbo import MboConstants
    
    mbo.setValue("ACTSTART", mbo.getDate("TARGSTARTDATE"), MboConstants.NOACCESSCHECK);
    mbo.setValue("OWNER", mbo.getUserInfo().getPersonId() , MboConstants.NOACCESSCHECK);


    Here is a blog post on using MboConstants for your reference. https://www.sharptree.io/blog/2022/2022-01-03-mbo-constants/



    ------------------------------
    Jason VenHuizen
    Sharptree
    ------------------------------



  • 4.  RE: Automation scripts.

    Posted 05-22-2023 08:27

    To add to the other answers....
    Don't forget to add condition/code so that these steps are not triggered for historic records ...

    If this code is executed for a historic record then it could trigger over bits of code that then fail because they don't override the attributes that they set... In that case Maximo would have difficulties loading/showing the record



    ------------------------------
    mark robbins
    Cohesive
    IBM Champion 2017-2023 Inclusive
    See my blog on Maximo support related topics here:
    https://www.linkedin.com/pulse/maximo-support-advice-from-non-ibm-engineer-article-mark-robbins/
    ------------------------------