Maximo Open Forum

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

    Posted 07-07-2024 07:49

    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?


    #Customizations

    ------------------------------
    Andrey Ilinskiy
    Handz.on
    ------------------------------


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

    Posted 07-18-2024 08:59

    Hi @Andrey Ilinskiy!

    Maybe MIF modifies before the script runs.

    I understand that it is possible in the script to use the postSave event to save it after it is saved, in order to try to make the script run after MIF modifies the data.

    def postSave(mbo):

    Regards!



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



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

    Posted 06-23-2025 05:43

    Hi Andrey,

    I hope your issue would have been resolved by now. Below is the solution that worked for me: 

    "If your requirement is to set the field values in afterMboData(ctx), then you would need to configure the field as Set Restricted in the object structure so that the MIF does not set this and then provide logic to set the value in your script.

    If you cannot Set Restrict the field in the object structure, there is an option to 'reset' the mbo field flag that will allow you to change the field value after it has been set by either the MIF or the MBO"

    mbo.setFieldFlag("description", MboConstants.NOSETVALUE, false);

    mbo.setValue("description", "abc", MboConstants.DELAYVALIDATION);

    Context APIs for the inbound processing of object structures - IBM Documentation 



    ------------------------------
    Aditi Jain
    Accenture
    ------------------------------