Maximo Open Forum

 View Only
  • 1.  Conditional default value

    Posted 04-17-2024 19:54

    Hi to all!

    I want to do something in Maximo that seemed simple and I've gotten stuck, although I admit it's the first time I've tried it.

    In the Preventive Maintenance application, for the worktype field (PM.WORKTYPE) I want to setup a conditional default value.

    If the loggedin user is from the PREV-GS security group, the WORKTYPE value in PM application must be 'GSMAN'. If the user is from another security group, it must be null.

    And I went around and couldn't move forward. I arrived at an automation script, but I don't know how to consult from there the security groups to which the user belongs.

    What I'm looking for is a solution, whatever it may be.

    Has anyone ever analyzed the APPFIELDDEFAULTS table? How can I register data here? I did it from the database, rebooted the system but it didn't do what I need (it didn't do anything).

    I use 7.6.1.2.

    Regards!


    #Customizations

    ------------------------------
    Martin Fabra
    ARSAT S.A. - Actively seeking employment
    ------------------------------


  • 2.  RE: Conditional default value

    Posted 04-18-2024 08:58

    Hello Martin!

    A script like the following could work:

    ## get the username of the logged-on user
    username = mbo.getUserInfo().getUserName().upper();
     
    ## get a temporary MBO set to see if the user belongs to the group and set a Boolean variable
    prev_GS = False if mbo.getMboSet("$AUTH", "GROUPUSER", "groupname IN ('PREV-GS') AND userid = '" + username + "'").moveFirst() == None else True;
     
    if (prev_GS):  mbo.setValue("WORKTYPE", "GSMAN");
    else:          mbo.setValueNull("WORKTYPE");


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



  • 3.  RE: Conditional default value

    Posted 04-19-2024 08:57

    Hi Jarred! 

    This is my code in python: 


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

    # Obtener la instancia del servidor Maximo
    mxServer = MXServer.getMXServer()

    ## get the username of the logged-on user
    username = mbo.getUserInfo().getUserName().upper();

    ## get a temporary MBO set to see if the user belongs to the group and set a Boolean variable
    prev_GS = False if mbo.getMboSet("$AUTH", "GROUPUSER", "groupname IN ('PREV-GS') AND userid = '" + username + "'").moveFirst() == None else True;
     
    if prev_GS:
        mbo.setValue("WORKTYPE", "GSMAN")
    else:
        mbo.setValueNull("WORKTYPE")

    It works but always, regardless of whether or not the user belongs to the "PREV-GS" security group

    Regards and thanks for your help!



    ------------------------------
    Martin Fabra
    ARSAT S.A. - Actively seeking employment
    ------------------------------



  • 4.  RE: Conditional default value

    Posted 04-20-2024 16:44

    Hi @Jade Warren! This script it's working fine so thank you very much for your help in solving it.

    from psdi.mbo import MboConstants

    ## get the username of the logged-on user
    username = mbo.getUserInfo().getUserName().upper();

    ## get a temporary MBO set to see if the user belongs to the group and set a Boolean variable
    prev_GS = False if mbo.getMboSet("$AUTH", "GROUPUSER", "groupname IN ('PREV-GS') AND userid = '" + username + "'").moveFirst() == None else True;
     
    if prev_GS:
        mbo.setValue("WORKTYPE", "GSMAN")
    else:
        mbo.setValueNull("WORKTYPE")

    Regards!



    ------------------------------
    Martin Fabra
    ARSAT S.A. - Actively seeking employment
    ------------------------------



Newest Episode
Ep. 5 | Make Manage Feel Like Home with Configuration, Not Customization

Watch Steven Shull and Phil Runion discuss how IBM Maximo Manage teams can make the system feel more familiar, useful, and aligned to their business through configuration instead of customization.

MORE by Naviam Episode 5 cover
Watch Episode 5
Also available: Ep. 4 | System Properties in IBM Maximo