Maximo Open Forum

  • 1.  Automation Script in the Assignment Section (Quick Reporting app)

    Posted 06-21-2021 17:23
    Hello,

    I'll like to build an automation script to perform the following:

    - A name will be entered in a custom field in the Assignment section of Quick Reporting.
    - The name entered on the custom field needs to be validated against the person table (displayname)...................... I'm pulling the same list of names from the Person table so the name is selected from a lookup.
    - If the two matches (entered name and displayname field in the person table), the person ID needs to be added to the assignment (specifically in the laborcode field...)

    Notes: Can I use the entered name to compare with the displayname field even though the value entered is not saved in the database?
    Here's what I have:

    from psdi.mbo import MboRemote
    from psdi.mbo import MboSetRemote
    from psdi.util import MXApplicationException
    from psdi.mbo import MboConstants
    from psdi.server import MXServer


    name = mbo.getString("NAME") <---------------------This is a custom attribute added to the assignment table.
    labor = mbo.getString("LABORCODE")


    if(name is not None):
    thisMboSet = mbo.getThisMboSet()
    thisMboSet.setWhere("name in(select displayname from person where displayname=" + name)
    thisMboSet.reset()
    thisMbo = thisMboSet.getMbo(0)

    personid = thisMbo.getString("PERSONID")

    thisMboSet.setValue("LABORCODE", personid, MboConstants.NOACCESSCHECK)
    thisMboSet.save()


    I have two launch points for testing purposes, (Object launch point, running after saving), and (attribute launch point, running after the custom attribute is updated with the assignee's name). Only one launch point runs at a time. I activate only one for testing but both are returning the same null pointer error.
    #Administration

    ------------------------------
    Jhonatan Jerez
    Electronic Data, Inc.
    ------------------------------


  • 2.  RE: Automation Script in the Assignment Section (Quick Reporting app)

    Posted 06-22-2021 08:44
    I don't understand this logic:

    "if(name is not None):
    thisMboSet = mbo.getThisMboSet()
    thisMboSet.setWhere("name in(select displayname from person where displayname=" + name)
    thisMboSet.reset()
    thisMbo = thisMboSet.getMbo(0)"

    If your custom attribute is on assignment and you want to set that assignment record, there is no reason to reset that. What I think you are trying to do is get the person record to get the personid. I think you'd want something like this:

    personSet=mbo.getMboSet("$EMXPERSON","PERSON","displayname=:name")
    personMbo=personSet.getMbo(0)
    if personMbo:
    personid=personMbo.getString("PERSONID")
    thisMbo.setValue("LABORCODE",personid,thisMbo.NOACCESSCHECK)


    That being said, I wouldn't personally feel comfortable with this customization. If you have 2 people named John Smith for example that would be a problem (display name is not unique) and you would randomly grab one of them. If you're on Oracle/DB2, that search would be case sensitive so the users would need to type it identically to how it is on the person record. And even setting LABORCODE to the PERSONID has the potential to fail because there is no requirement that they match and we have seen multiple systems where they don't.

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



  • 3.  RE: Automation Script in the Assignment Section (Quick Reporting app)

    Posted 06-22-2021 12:00
    Thanks, Steve

    In this case, every person has a unique code tied to their name so it will return only one name/person. The code is actually the main reason to get this set up, so instead of going through the list of values from a lookup in the Labor field of Assignments, the user is going to enter the code (three digits) and tab out of the custom field. The name associated with the code will be then populated and the labor code associated with the person (which is the same as the personid). 

    Thanks again for your help,

    Jj

    ------------------------------
    Jhonatan Jerez
    Electronic Data, Inc.
    ------------------------------



  • 4.  RE: Automation Script in the Assignment Section (Quick Reporting app)

    Posted 06-23-2021 10:29
    Hello Steven,
    Thanks for the help. Below is the working code in Maximo:

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

    #Custom field in the Assignment Object, NAME.

    name = mbo.getString("NAME")

    personSet=mbo.getMboSet("$EMXPERSON","PERSON","displayname=:name")
    personMbo=personSet.getMbo(0)

    if(personMbo > 0):
    personid=personMbo.getString("PERSONID")
    mbo.setValue("LABORCODE",personid,mbo.NOACCESSCHECK)

    ------------------------------
    Jhonatan Jerez
    Electronic Data, Inc.
    ------------------------------



  • 5.  RE: Automation Script in the Assignment Section (Quick Reporting app)

    Posted 06-23-2021 10:56
    Here's what I don't understand.  There is no assignment section in Quick Reporting.  Has there been a customisation done?

    There is also no person-related information on the assignment in work order tracking, rather it's labor related.  So in your set-up does the personid=laborcode?

    But let's get to the matter.  You want a freetext field (ASSIGNMENT.DISPLAYNAME), that if there is a match to the same (PERSON.DISPLAYNAME) in the PERSON application, then pull through the PERSONID?  The freetext field has a lookup attached to it, and if selected then return the PERSONID to the ASSIGNMENT.LABORCODE field.

    So your data set-up is:
    • PERSONID = 998
    • DISPLAYNAME=Mary Anne
    • LABORCODE=998

    Use case: As a user, I only know the name "Mary Anne", so I enter this in the custom field.  It then returns 998 in to the laborcode field.

    So am I to understand that the custom work is to avoid the user from doing this:
    1. Select the lookup from the Labor field
    2. Enter Mary
    3. Select the Enter/Return key
    4. Select the Labor entry the matches your criteria

    So, what if the user enters "Mary"?  That does not match "Mary Anne".  Do you want a lookup list to appear?

    Have you looked at the type-ahead feature?  See https://www.youtube.com/watch?v=DQF_IhputUY  I think this video may have your answer, but only if the personid=laborcode.  Do take Steve's advice into acccount, even though you have said that the issue outline by him won't occur.

    ------------------------------
    Craig Kokay
    ISW
    Maximo Practice Manager
    eMail: ckokay@isw.net.au
    Phone: +61-411-682-040

    IBM Champion 2021
    ------------------------------



  • 6.  RE: Automation Script in the Assignment Section (Quick Reporting app)

    Posted 06-23-2021 11:25
    Thanks Craig,

    I have this working already, thanks for your input. 

    There are customizations that I simply didn't include in my post. So in my case, there's an assignment section in Quick Reporting, there's a custom lookup as well, and the Person record has a unique code as well and the end-user is not searching by name, instead, is entering the unique code and only one record is going to be retrieved. 

    Thanks again,

    Jhonatan Jerez

    ------------------------------
    Jhonatan Jerez
    Salt Lake City International Airport
    ------------------------------