Maximo Open Forum

 View Only
  • 1.  Auto Script - Labor Record Creation

    Posted 07-11-2023 11:07

    Hi All, 

    I have been working on a script that auto creates a labor record when a new user is created. Here is the manual process I follow today:

    1. I manually create a new a User in MAS (This process will stay the same).
    2. New User record is automatically created in Manage.
    3. New Person record is automatically created in Manage.
    4. I manually create the user's labor record in Manage.

    The auto script below successfully creates a new labor record when I manually create a Person record. However, when a new user is created through MAS and the person record is automatically created, the script does not run. Could someone please assist?

    from psdi.mbo import MboConstants


    # Get the personid value from the person object
    # Check if the personid record is newly created (isNew() method checks if the record is new)
    if mbo.isNew():

        personid = mbo.getString("PERSONID")
        # Check if the personid is not empty
        if mbo:
            # Get the Labor object and create a new labor record
            # Get the LaborCraftRate object and create a new laborcraftrate record
            laborSet = mbo.getMboSet("$LABOR", "LABOR", "1=0")  # Create an empty labor set
            labor = laborSet.addAtEnd()
            laborCraftRateSet = labor.getMboSet("$LABORCRAFTRATE", "LABORCRAFTRATE", "1=0")  # Create an empty laborcraftrate set
            laborCraftRate = laborCraftRateSet.addAtEnd()
            # Set the labor id to match the personid
            # Set the craft code and laborcode values for the laborcraftrate record
            labor.setValue("LABORCODE", personid)
            laborCraftRate.setValue("CRAFT", "MAINT")
            laborCraftRate.setValue("LABORCODE", personid)
            laborCraftRate.setValue("DISPLAYRATE", "35")
        
            # Save the labor record
            laborSet.save()

            # Save the laborcraftrate record
            laborCraftRateSet.save()


    #MaximoApplicationSuite

    ------------------------------
    Carlos Mestre
    Home Depot
    ------------------------------


  • 2.  RE: Auto Script - Labor Record Creation

    Posted 07-11-2023 20:10

    Hi Carlos, what is the launch point you are using?  Are there any errors in the log or and indication the script was launched?



    ------------------------------
    Steven Hauptman
    IBM
    ------------------------------



  • 3.  RE: Auto Script - Labor Record Creation

    Posted 07-12-2023 11:14

    Hi Steven, 

    This script has an attribute launch point on attribute Personid, object Person. I checked the logs, and it looks like the script was launched. See the logs message below:

    [7/11/23, 19:40:53:703 GMT] 00006e30 SystemOut                                                    O 11 Jul 2023 19:40:53:703 [DEBUG] [MXServer] [CID-MXOSLC-568003] PERSONScriptMboEventListener eventAction called. for script THD_LABOR launch point THD_LABOR



    ------------------------------
    Carlos Mestre
    Home Depot
    ------------------------------



  • 4.  RE: Auto Script - Labor Record Creation

    Posted 07-12-2023 16:35
    Edited by Steven Hauptman 07-13-2023 16:28

    Hi Carlos,

    I saw some odd behavior in both scenarios.  Removing the two saves seems to resolve things and I saw a labor record created both manually and via MAS.  In general, save should be avoided in a script, especially a field validation.  Let me know if that adjustment works for you.



    ------------------------------
    Steven Hauptman
    IBM
    ------------------------------



  • 5.  RE: Auto Script - Labor Record Creation

    Posted 07-14-2023 10:46

    Steven, that worked! Thank you so much!



    ------------------------------
    Carlos Mestre
    Home Depot
    ------------------------------



  • 6.  RE: Auto Script - Labor Record Creation

    Posted 07-17-2023 09:06

    Hi, is this solution usable in 7.6.1.2?



    ------------------------------
    Stevie Holloway
    Tufts University
    ------------------------------



  • 7.  RE: Auto Script - Labor Record Creation

    Posted 07-17-2023 16:21

    Yes, it should work in 7.6.1.2 as well.



    ------------------------------
    Steven Hauptman
    IBM
    ------------------------------