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
------------------------------
Original Message:
Sent: 12-21-2021 11:42
From: Steven Shull
Subject: Field Level class on Duplicating an MBO
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
Original Message:
Sent: 12-21-2021 05:44
From: Meghana Siriveli
Subject: Field Level class on Duplicating an MBO
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
------------------------------