Maximo Open Forum

 View Only
  • 1.  Maximo autoscript - disallow future date when changing work order status.

    Posted 07-08-2021 15:23
    Is it possible to get date and time from logged in user's locale and timezone and compare that date and time with work order status change date? 
    We dont want user to select future date when changing work order status and our instance is used across globe and servers are in US.  Below is the code that i wrote but its not working for our users in Asia region.

    load("nashorn:mozilla_compat.js");
    importPackage(Packages.psdi.mbo);
    importPackage(Packages.psdi.server);
    if (mbo!== null )
    {
    //service.log("********************GLW_WOSTDATE********************************");

    var statusdate1 = mbo.getDate("ASOFDATE");
    if (statusdate1.getTime() >= MXServer.getMXServer().getDate().getTime())
    {
    errorkey="BADDATE"; errorgroup="GLWWO";
    }
    }
    #WorkManagement

    ------------------------------
    Hardik PAtel
    Corning Inc
    ------------------------------


  • 2.  RE: Maximo autoscript - disallow future date when changing work order status.

    Posted 07-08-2021 16:24
    Try eliminating the .getTime() aspects of each and use the .after method of date. Something like:

    if (statusdate1.after(MXServer.getMXServer().getDate()))

    I'd also use service.error(group,key) instead of the errorkey & errorgroup implicit variable functionality (provided you want the script to stop).


    ------------------------------
    Steven Shull
    Projetech Inc.
    ------------------------------