Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  MIF processor ingror changes of processing Mbo in scripts

    Posted Sun July 07, 2024 04:22 AM

    Hi!

    We using IBM Maximo 7.6.1.3

    I have a next problem. We have some customization on ASSET mbo, made with scrips on SAVE.

    Script set svalue of the attribute, based on the value in this attribute and some other rules. 

    In UI it works fine, no problems. 

    But, when we have changes of Mbo from MIF, script acts, but any changes of primary MBO are ignored.

    It means:

    we have mbo with attribute "ZZZ" (even tried with description) = "111". 

    we have in import json (xml. csv doesnt make difference) the value ZZZ  = "123"

    Script should change this value to 321 by mbo.setValue("ZZZ", "321")

    after mbo saved value is "123".

    what interesting, in debugging, i have that script setValue ignored:

    System.out.println("ISA: mbo.getString(\"ZZZ\") = " + str(mbo.getString("ZZZ"))); 
    #output zzz = 123 as in JSON 
    mbo.setValue("ZZZ","321")
    System.out.println("ISA: mbo.getString(\"ZZZ\") = " + str(mbo.getString("ZZZ")));
    #output zzz = 123 as in JSON 

    I tried to do same way, but in script for inregration (objectscruture Inbound processing)

    Result is same:

    def afterMboData(ctx):
        System.out.println("ISA: afterMboData " + str(ctx));
        System.out.println("ISA: afterMboData " + str(ctx.isPrimary()));
        System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMbo()));
        if ctx.getPrimaryMbo() and ctx.getPrimaryMbo().getName() == "ASSET":
            System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMbo().getString("DESCRIPTION")));
    # output as in JSON
            ctx.getPrimaryMbo().setValue("DESCRIPTION",  "...");
            System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMbo().getString("DESCRIPTION")));
    # output as in JSON   
        if ctx.getPrimaryMboSet() and  ctx.getPrimaryMboSet().getName() == "LOCATIONS" and ctx.getPrimaryMboSet().getMbo(0):
            System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMboSet().getMbo(0).getString("DESCRIPTION")));
    # output as in JSON
            ctx.getPrimaryMboSet().getMbo(0).setValue("DESCRIPTION",  "...");
            System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMboSet().getMbo(0).getString("DESCRIPTION"))); 
    # output as in JSON
    
    def preSaveRules(ctx):
        System.out.println("ISA: preSaveRules " + str(ctx));
        System.out.println("ISA: preSaveRules isPrimary " + str(ctx.isPrimary()));
        System.out.println("ISA: preSaveRules getPrimaryMbo " + str(ctx.getPrimaryMbo()));
        System.out.println("ISA: preSaveRules getPrimaryMbo is locations" + str(ctx.getPrimaryMbo().getName() == "ASSET"));
        if ctx.getPrimaryMbo() and ctx.getPrimaryMbo().getName() == "ASSET":
            System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMbo().getString("DESCRIPTION")));
    # output as in JSON
            ctx.getPrimaryMbo().setValue("DESCRIPTION",  "...");
            System.out.println("ISA: afterMboData " + str(ctx.getPrimaryMbo().getString("DESCRIPTION")));
    # output as in JSON

    Any ideas, why it so and how to manage it?



    ------------------------------
    Andrey Ilinskiy
    Handz.on
    https://www.on.de/
    München
    ------------------------------


  • 2.  RE: MIF processor ingror changes of processing Mbo in scripts

    Posted Mon July 08, 2024 09:05 AM

    This is functioning as intended in the MIF. When values are passed into the MIF, a flag is set on the attribute to not accept future changes to the value. This is to avoid java classes overriding the value explicitly passed into Maximo from an external system. 

    For the MIF, you could mark the attribute as restricted and use the OSIN automation script approach to set the value. When you mark it as restricted, the MIF does not set the value automatically and is expected that a java class or automation script will read the message body to process it. A good example of a field that is often restricted out of the box is STATUS. We don't want the MIF to directly update the status but instead invoke the proper change status flow.

    Another option is you can clear the NOSETVALUE flag and then you would be able to change the value.  We cover this in the afterMboData section here: https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/integration/osevents



    ------------------------------
    Steven Shull
    ------------------------------



  • 3.  RE: MIF processor ingror changes of processing Mbo in scripts

    Posted Mon July 08, 2024 01:38 PM

    Thank Steven! 

    I will try this. But for me, it was news that it works that way because it makes us write scripts twice when you want to customize any business requeriemnst: first for UI and now same for integration. 

    This is another plus in favor of Java



    ------------------------------
    Andrey Ilinskiy
    Handz.on
    https://www.on.de/
    München
    ------------------------------



  • 4.  RE: MIF processor ingror changes of processing Mbo in scripts

    Posted Mon July 08, 2024 01:46 PM
    Edited by Steven Shull Mon July 08, 2024 01:47 PM

    It wouldn't matter if you had a java class or an automation script here. The MIF suppresses the set value flag to prevent out of the box java classes from changing the value someone provided in an integration. The expectation is that data from the sending system is accurate or it wouldn't be passed into the system. 

    You also can get away with a single automation script. You just need to clear the NOSETVALUE flag in your existing script prior to trying to set the value. I referenced the OSIN automation script example just because that is where it is in our documentation but you can do that in any script launch point (such as object save for example). 

    ------------------------------
    Steven Shull
    ------------------------------