Maximo Open Forum

 View Only
  • 1.  Automation Scripts

    Posted 11-19-2021 04:13
    Hi Folks

    I'm more familiar with SQL than I am python, would appreciate it if someone could help me out with the correct syntax for the bolded section for my automation script, thanks in advance

    Cheers

    from psdi.mbo import MboConstants
    from psdi.server import MXServer

    if mbo.isNull("GLACCOUNT"):
    errorgroup ="WORKORDER"
    errorkey = "GLAcctIncomplete"

    else:
    mbo.getString("GLACCOUNT") like "%-??????"
    errorgroup ="WORKORDER"
    errorkey = "GLAcctIncomplete"
    #Customizations
    #EverythingMaximo

    ------------------------------
    Peter McDonald
    Prima58
    ------------------------------


  • 2.  RE: Automation Scripts

    Posted 11-22-2021 08:58
    FYI - I'm new to automation scripts too. I found this quick reference guide helpful (although I don't think it helps you with your current question).
    https://bportaluri.com/sdm_downloads/automation-scripts-quick-reference

    ------------------------------
    User 1972
    ------------------------------



  • 3.  RE: Automation Scripts
    Best Answer

    Posted 11-22-2021 09:13
    Maybe something like this?

    from psdi.mbo import MboConstants
    from psdi.server import MXServer

    if mbo.isNull("GLACCOUNT"):
      errorgroup ="WORKORDER"
      errorkey = "GLAcctIncomplete"

    elif mbo.getString("GLACCOUNT").find("-??????") > -1:
      errorgroup ="WORKORDER"
      errorkey = "GLAcctIncomplete"

    Hope this helps,

    ------------------------------
    Alex Walter
    A3J Group, LLC
    ------------------------------



  • 4.  RE: Automation Scripts

    Posted 11-22-2021 17:06
    Hi Alex

    Thanks for your feedback, this worked perfectly for my needs, appreciate it

    Cheers
    Peter

    ------------------------------
    Peter McDonald
    Prima58
    ------------------------------



  • 5.  RE: Automation Scripts

    Posted 11-22-2021 09:18
    If you're really sure you want to throw the same error for both conditions, simplify it with:

    from psdi.mbo import MboConstants
    from psdi.server import MXServer
    
    # Declare a variable for the value of the GLACCOUNT attribute
    glAccount = mbo.getString('glaccount')
    
    if glAccount is None or glAccount.endswith('-??????'):
        errorgroup = 'WORKORDER'
        errorkey = 'GLAcctIncomplete'​



    Otherwise:

    from psdi.mbo import MboConstants
    from psdi.server import MXServer
    
    # Declare a variable for the value of the GLACCOUNT attribute
    glAccount = mbo.getString('glaccount')
    
    if glAccount is None:
        errorgroup = 'WORKORDER'
        # make a different error message for this
        errorkey = 'GLAcctIsNull'
    
    elif glAccount.endswith('-??????'):
        errorgroup = 'WORKORDER'
        errorkey = 'GLAcctIncomplete'


    ------------------------------
    Travis Herron
    Pensacola Christian College
    ------------------------------



  • 6.  RE: Automation Scripts

    Posted 11-22-2021 09:43
    Also...a cleaner way to through an error is to use the service.error() method...

    service.error("ERRORGROUP, "ERRORKEY", [params]);

    ------------------------------
    Jade Warren
    Great River Energy
    ------------------------------



  • 7.  RE: Automation Scripts

    Posted 11-22-2021 21:23
    you might be able to use
    elif mbo.getString("glaccount").endswith("-????")

    ---------------------------------
    Jeff Kish
    interloc solutions
    ---------------------------------