Maximo Open Forum

 View Only
  • 1.  Field Level class on Duplicating an MBO

    Posted 12-21-2021 05:44
    Hi All,

    I have a question regarding duplicate method on a Mbo.

    Will Field level class logic gets executed when duplicating an mbo ?

    Scenario:

    We have a Custom field which stores total cost and the logic to calculate the cost is defined in the field level class of an OOB field.
    When the mbo is duplicated via select action using mbo.duplicate() method, it is copying the total cost of mbo to duplicated mbo. But when the underlying values that are used to calculate the cost are updated and then the mbo is duplicated, the dupmbo is not reflecting the new value even after save but is only copying the values from mbo that was duplicated.

    My Query here is in case of duplicating, will Maximo not consider the logic of field level class to re calculate the total cost as per the updated underlying values?

    Thanks in Advance.



    #Customizations

    ------------------------------
    Meghana Siriveli
    ------------------------------


  • 2.  RE: Field Level class on Duplicating an MBO

    Posted 12-21-2021 11:42
    As for the specific question if a field class isn't invoked on duplication, that is correct. Values that are copied over suppress validation/action. This is for a few reasons but a big one is the order fields are set matters. For example, if during the duplication you set the ASSETNUM on the WORKORDER prior to setting the SITEID that would cause errors. Without each object defining the order that fields need to be set, most would fail during duplication. Some objects then implement additional logic to ensure values are valid with the current state of the data. 

    That being said, I'm not sure I understand how you're hitting your scenario. You mention that you have a custom total cost field that is populated via a field class on a different attribute. An underlying change occurs prior to duplication that will eventually adjust the total cost but hasn't yet on the original record (not sure if this is related to asynchronous delay or the calculation actually occurs on save of the record). You then duplicate the original record prior to the original record being saved? 

    The reason I'm confused is the standard duplicate event on a bean class will force a save of the original record to avoid scenarios like this. If you have an automation script that is calling your own mbo.duplicate() logic and doing it on something that has been modified then that makes sense why it's an issue but it's not clear why you wouldn't be utilizing the standard bean class DUPLICATE event. Are you duplicating something that's not the main object of the application? 

    You can write an automation script with the name OBJECTNAME.DUPLICATE to implement additional logic. You can also define custom fields to be skipped during the duplication event if you don't want them to come over from the original record.

    ------------------------------
    Steven Shull
    IBM
    ------------------------------



  • 3.  RE: Field Level class on Duplicating an MBO

    Posted 12-22-2021 23:25
    Hi Steven,

    Thanks for the response.

    We have designed the total cost to calculate at the save of the object and also when the field with field class defined is modified and after certain point of status, the records becomes read only. So the scenario goes like, The current Record is saved with correct total cost and is at read only point, then underlying values that constitute total cost gets updated. So there is no chance for the user to go and update the already saved record with certain status and then record is duplicated .At this point, We are expecting for our field class to execute and calculate the total cost with updated values, which is not happening.

    and Yes, the object being duplicated is not the main object of the application.

    I have managed to update the total cost correctly with an automation script .We are just checking if we can do the same by modifying anythinfg in the java code instead of autoscript.

    Also Can you please let usknow if there is any method to find if the mbo is a duplicated mbo in autoscript?
    We haven't used OBJECTNAME.DUPLICATE script, which consists dupmbo as implicit variable.

    Thanks in Advance.


    ------------------------------
    Meghana Siriveli
    ------------------------------



  • 4.  RE: Field Level class on Duplicating an MBO

    Posted 12-26-2021 13:56
    Hi Meghana,

    There are ways in Java customization to check if the mbo is duplicated mbo or not and you can write a simple logic to check the same.You can check the OOTB WO class and you can write a similar logic to implement in auto script which I have not done so far.

    Let me know if you need any further assistance and will be happy to assist.

    Regards,
    Mahadevan.

    ------------------------------
    Mahadevan Ramakrishnan
    ------------------------------



  • 5.  RE: Field Level class on Duplicating an MBO

    Posted 12-27-2021 03:39
    Hi Mahadevan,

    Thanks for the response.

    Could you please let me know the ways or any article references you have to check if mbo is a duplicated mbo or not?

    Thanks
    Meghana S

    ------------------------------
    Meghana Siriveli
    ------------------------------



  • 6.  RE: Field Level class on Duplicating an MBO

    Posted 12-27-2021 12:28

    There's not a generic attribute/method to check if a MBO is a duplicated record in either an automation script or java code. What occurs during duplication is the duplicate() method on the MBO calls the copy method on the MBO and in that method you have access to the original and new MBO. Past that there's no indicator that the new MBO is a duplicate of an existing record.

    You could create the MBONAME.DUPLICATE script and force a recalculation or set some sort of flag to indicate that it's a duplicate. You could also prevent duplication if the record has been modified in some way. Since you're calling the mbo.duplicate() event (not sure if you're doing that in Java or an automation script), check if the mbo is modified (mbo.isModified()) prior to calling the duplicate and throw an error that they need to save first. Or explicitly call a save before the duplication. 

    There's a ton of options and it really just depends on what you want to do and how to determine the appropriate steps to take. 



    ------------------------------
    Steven Shull
    IBM
    ------------------------------