Maximo Open Forum

 View Only
  • 1.  Setting a default value for MRLINE.STORELOC

    Posted 03-29-2022 18:59
    I'm trying to start using Materials Requisitions with a certain set of users, and I need them to ONLY requisition from one, particular, well-controlled storeroom.  For now.  Sometime down the road, that may change, which is why I'm hesitant to just set the "Default Storeroom for Self-Service Requisitions" on their User profiles and move on.  Here's a summary of what I've done so far:

    I took CREATEDR.XML and for that Wizard part where you go through Step 1: Shipping and Charge Info, Step 2: MR Lines, Step 3: Review and Confirm -- in the XML that's all done with an include tag, and it's including something from LIBRARY.XML.  I went to LIBRARY.XML, grabbed that whole wizard portion, and pasted it into CREATEDR.XML twice, and changed the ControlID's in that second pasting so I could import it.  With it imported, I can make further changes via Application Designer.

    I set up and applied custom SigOptions so that if this display the first "pasting" of the Wizard; otherwise, show the second "pasting".  That's all working correctly.

    The "if this" is that I added a synonym value on the MRTYPE domain.  Synonym is MYSYNONYM, and the base maxvalue behind-the-scenes is STANDARD.

    At the top of the CREATEDR.XML I added radio buttons where the user can choose between basically STANDARD or MYSYNONYM.

    I customize the second "pasting" -- removing a bunch of unnecessary fields, and --most importantly-- adding a Default Value control for the STORELOC attribute.  On Insert, set the value to MYSTORE.  

    So basically what should happen (and does happen) is if the user chooses STANDARD, they'd get the original OOTB Desktop Requisition experience.  If they choose MYSYNONYM, they get a simplified experience where they have to fill out fewer fields, and they can only choose from Items in one particular storeroom.

    Here's where I'm having a problem:  I add an MRLine, and the STORELOC defaults to MYSTORE as I wanted.  Then I go to enter an ItemNum.  If I use the Lookup menu, it only shows the Items in that Storeroom.  Excellent!  But if I choose one from the Select Value menu, or if I had straight typed it in the field, when it validates it is clearing out the value of the Storeroom field.  I presume that's because my User profile has no Default Storeroom. . .

    I update my Default Storeroom to MYSTORE and try again.  This time it works exactly how I wanted it to work. . .

    I again update my Default Storeroom to OTHERSTORE and try again.  This time, I enter the ItemNum and it sets the STORELOC to OTHERSTORE, and then I get an error in the ItemNum field because that Item isn't in OTHERSTORE's Inventory.

    I even tried a simple script to (hopefully) force it to put MYSTORE back as the STORELOC value after Maximo does whatever it does to validate, but it didn't work.  Here's the script:
    from psdi.mbo import MboConstants
    
    if mrType == 'MYSYNONYM':
    
        mbo.setValue('storeloc', 'MYSTORE', MboConstants.NOACCESSCHECK)

    This has an Attribute launchpoint on ITEMNUM, object is MRLINE, the mrType variable is bound to MR.TYPE, and the storeloc variable is bound to STORELOC.   I've tried this with both the Validate and Run Action events.

    Any ideas on how I can make this work?  (Preferably without setting values in the Users' Default Storeroom)


    #Administration
    #EndUser
    #EverythingMaximo
    #Inventory

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


  • 2.  RE: Setting a default value for MRLINE.STORELOC

    Posted 03-30-2022 12:47
    Done more research and experimentation and, though no closer to a solution, I at least understand the problem better.

    The field class psdi.app.mr.FldMRLineItemnum works like this (via FldMRLineItemnum (maximo.wiki)):
    1. When itemnum is set, the storeroom is always cleared.
    2. At this moment, the effort to find a default storeroom will take place. It looks for a storeroom whose inventory record for this itemnum is stocked. If the default storeroom is set in the user profile, this storeroom will be checked first. If one of such storeroom is found, this one will be set as the storeroom for the mrline.
    3. If a such storeroom is not found, the default vendor from the invvendor record for this item will be set to the vendor, and the information for vendor including manufacturer, catalogcode, modelnum, orderunit will be copied to mrline. Otherwise, both storeroom and vendor will be left blank, and it will be considered as a direct request.
    4. After all the above, if vendor is found, the default price will be calculated according to the common default order price logic. Agreements will be considered.



    Additionally, when I don't have a Default Value control setting the value of the storeroom, it behaves as described above, and, for the item I'm using as my test case (because it is stored in multiple storerooms), it chooses the alphabetically-first storeroom -- which is not the one that I ultimately need.  When I use a Default Value control, when I add the row, the storeroom value is set how I want it, but then I enter the ItemNum and the storeroom ends up NULL, instead of even choosing the "wrong" storeroom.

    My script, as posted above, isn't working.  It's not evaluating the IF statement how I want, probably because it (the parent MR record) doesn't actually exist yet (it's in memory but not committed).  I added a couple of extra mbo.SetValue() statements, tested, and nothing worked; then I removed the IF statement and everything else worked -- still ended up with a NULL for the Storeroom though.

    Anyone have handy the instructions on how to get the value from the non-committed parent record and use it in the script?  Or know how to change the preference of which storeroom it chooses, instead of just the alphabetically-first one at the User's Site that stocks the Item?

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



  • 3.  RE: Setting a default value for MRLINE.STORELOC

    Posted 03-31-2022 19:42
    Travis,

    If you're on a record that has a parent, you should be able to access that parent in memory using the getOwner() method on the object. Something like this should work:

    mr = mbo.getOwner()
    if mr and mr.getString("MRTYPE") == "MYSYNONYM":
        mbo.setValue('storeloc', 'MYSTORE', MboConstants.NOACCESSCHECK)

    Hope this helps,

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



  • 4.  RE: Setting a default value for MRLINE.STORELOC

    Posted 04-01-2022 16:51
    That's exactly what I want it to do, yes.  getOwner() is what I was missing. . .

    However, when I use that in my script, Maximo keeps throwing a NullPointerException when it reaches the line to set the Storeroom value.  Ideas?

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



  • 5.  RE: Setting a default value for MRLINE.STORELOC

    Posted 04-01-2022 17:10
    This is looking very much like this thread: Script to set value on object initialise - Forums - IBM Support -- and no answer was ever found; not good.

    I've also tried adapting this (IBM Maximo Tips: Maximo Automation Script setting values while Initializing) into Jython and putting it in my script; no success yet.

    I'm currently either getting a NullPointerException or it acts like it ran the code (and it does the setFieldFlag actions I'm giving it, so it is running the code) but it totally ignores any setValue or setValueNull commands.

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



  • 6.  RE: Setting a default value for MRLINE.STORELOC

    Posted 04-04-2022 08:37
    Travis,

    I could be wrong, but I remember having to set the STORELOCSITEID value on the MR Line before setting the STORELOC value. Try something like:

    mr = mbo.getOwner()
    if mr and mr.getString("MRTYPE") == "MYSYNONYM":
        mbo.setValue('storelocsiteid', 'BEDFORD')
        mbo.setValue('storeloc', 'CENTRAL')

    Hope this helps,

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



  • 7.  RE: Setting a default value for MRLINE.STORELOC

    Posted 04-04-2022 16:01
    Good thought, but that doesn't seem to have improved my situation any.

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



  • 8.  RE: Setting a default value for MRLINE.STORELOC

    Posted 04-05-2022 14:03
    I think I've finally got it working!

    I made the script with an Attribute Launch Point on the LINETYPE field -- this sets the storeroom value and makes it readonly.  Then after an ITEMNUM is entered, I have to again set it to readonly with another script (Attribute Launchpoint on ITEMNUM).

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