Adding on a bit more to Prashant's response, take WO as an example. When its status is APPR, by default you can no longer add in planned materials. Conversely, while it's WAPPR you can't add in actual labor. The canAdd/canDelete event fires immediately prior to the framework trying to create the MBO record which makes it a more efficient place to check whether or not that action should be allowed. You could wait until the user tries to save and throw an error, but that would be a poor user experience.
Allow Object Deletion is pretty straight forward and similar to any other script. If you throw an error, using service.error("messageGroup","messageKey") for example, Maximo won't allow it to be deleted.
Allow Object Creation is a little bit different as there is no implicit mbo variable. This is because you're trying to determine if a record can be added, thus it doesn't exist yet. So instead of mbo as an implicit variable, you have mboset to reference the set the record would be added to (IE LABTRANS, POLINE, etc.). You then again throw an error when you don't want them to create the record.
In both cases, you often look at the owner record (IE the WORKORDER or PO header). You get the owner mbo using mbo.getOwner() for allow object deletion and mboset.getOwner() for allow object creation.
------------------------------
Steven Shull
Director of Development
Projetech Inc
Cincinnati OH
------------------------------
Original Message:
Sent: Sat October 17, 2020 06:46 AM
From: MAX092012
Subject: Working Example - Allow Object Creation and Allow Object Deletion in Automation Script
Hi All,
I'm just trying to understand what kind of functionality would work in Allow Object Creation/Allow Object Deletion event in Object Launch point. If anyone has a working example , kindly share.
------------------------------
MAX092012
------------------------------
#AssetandFacilitiesManagement
#Maximo