Maximo

Maximo

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

Β View Only
  • 1.  Script to display warning message if actual hours is greater 12 hours

    Posted Fri October 22, 2021 05:10 PM
    Our users have a pretty simple request that I'm struggling with. They would like Maximo to display a warning message when they enter a LABTRANS record greater than 12 hours for a basic sanity check.

    At first, I tried a simple attribute script on LABTRANS.REGULARHRS. If LABTRANS.REGULARHRS is greater than 12, then send a warning message. This didn't seem to work. The reason I suspect is because LABTRANS.REGULARHRS can be a calculated field based on the start date and time and the end date and time. 

    The next thought I had was an object level script on LABTRANS that fired at validation that gave the user a Yes/No option. However, I'm not sure how to stop the save process if the user selects No indicating that they want to update the hours they entered and not save the record yet. 

    Has anyone else done something similar or have any ideas to accomplish what I'm trying to do?

    ------------------------------
    Tim Jones
    Software Engineer
    Kaiser Aluminum
    Sherman TX
    (903) 892-5821
    ------------------------------

    #AssetandFacilitiesManagement
    #Maximo


  • 2.  RE: Script to display warning message if actual hours is greater 12 hours

    Posted Mon October 25, 2021 07:52 AM
    I'm a bit surprised that they would suppress validation/action on the attribute but if you're OK doing the object based approach, when they say No I would throw an error which would prevent the record from being saved. The user would see the error message which isn't necessarily the greatest of flows but it's the only way to stop it when you're in the process of saving the record.

    ------------------------------
    Steven Shull
    ------------------------------



  • 3.  RE: Script to display warning message if actual hours is greater 12 hours

    Posted Mon October 25, 2021 10:33 AM
    Edited by System Admin Wed March 22, 2023 11:46 AM

    Tim,

    If they just want a warning as a basic sanity check, you'd really just want to enter field level validation on the LABTRANS.REGULARHRS field. Even if you're entering a start and end time (instead of the regularhrs), it would trigger the message when validating the End Time field as in this screen shot:


    Here are the steps I  followed to accomplish this.

    Create a new Message in the Database Configuration application

    1. Go to System Configuration  >>  Platform Configuration >> Database Configuration
    2. Under the More Actions menu, click "Messages".
    3. Click "New Row", and enter the following values:
      • Message Group: MYGROUP
      • Message Key: MYKEY1
      • Display Method: MSGBOX
      • Message ID Prefix: BMXZZ
      • Message ID Suffix: E
      • Message ID: (this value will autopopulate)
      • Display ID: Checked
      • Value:  Labor Entry is greater than 12 hours. Are you sure you want to save this entry?
      • Buttons: Check the boxes for Cancel, Yes
    4. Click the OK button to save the new message. (It is not necessary to do a dbconfig.)
    Create a new Automation Script with Attribute Launch Point

    1. Go to System Configuration  >>  Platform Configuration >> Automation Scripts
    2. Under the More Actions menu, click Create >> Script with Attribute Launch Point.
    3. Enter these properties for the Step 1 of 3 screen:
      • Launch Point: LABHRS1
      • Object: LABTRANS
      • Attribute: REGULARHRS
      • Events: Validate
      • Script: New
    4. Click Next, then enter these properties for the Step 2 of 3 screen:
      • Script: LABORHRS1
      • Log Level: Error
      • Script Language: python
      • Click "New Row" under Variables and enter the following properties:
      • Variable: REGULARHRS
      • Variable Type: INOUT
      • Binding Type: ATTRIBUTE
      • Launch Point Attribute: REGULARHRS
    5. Click Next, for the script, enter the following:
      regularhrs = mbo.getMboValue("REGULARHRS").getDouble()
      
      if (regularhrs > 12):
         warngroup = "MYGROUP"
         warnkey = "MYKEY1"
    6. Save and then test by making a new labor entry.

    This gives users the standard behavior with a sanity check and will allow them to either "Use My Value" or "Go Back".

    If you want  to enforce it so that a user cannot enter an entry > 12 hours, you could change the code in step 5 from "warngroup" and "warnkey" to "errorgroup" and "errorkey". If you do this though, you may also want to consider adding extra code that checks the user's  security groups and allows them to save an entry >12 if they're in a specific security group (e.g. - a  supervisor, etc.)


    #AssetandFacilitiesManagement
    #Maximo


  • 4.  RE: Script to display warning message if actual hours is greater 12 hours

    Posted Tue October 26, 2021 12:58 PM
    Hey @Christopher Westfall - big shout out for putting this all together. Great write up on the script. πŸ‘β€‹

    ------------------------------
    Jason Verly
    Reliability Engineering Manager
    Agropur US
    Le Sueur MN
    ------------------------------



  • 5.  RE: Script to display warning message if actual hours is greater 12 hours

    Posted Tue October 26, 2021 05:39 PM
    Thank you for the response. I turned on some logging and the script seems to be working properly. I have a log statement right before the warning message and I get that but the message is not displaying. I must be doing something dumb but I haven't figured out what that is.  


    ------------------------------
    Tim Jones
    Software Engineer
    Kaiser Aluminum
    Sherman TX
    (903) 892-5821
    ------------------------------