I have a custom application and custom object. The application has a table with a details section and toggledeleterow for each row. I created an automation script using object launch point and event
Allow Object Deletion.
When the user clicks the garbage can to delete the record, the script checks if the record being deleted is referenced anywhere else.
If it's not, the row is marked for deletion and the UI show that row with a strike through. This works, just like a standard delete button.
If the record is used somewhere else, the script sets the field record status to inactive and displays a message letting the user know the record can't be deleted, but it was set to inactive instead.
mbo.setValue("RECSTATUS","Inactive");
logger.debug("NOT Allowed to Delete - itemsFound = "+str(itemsFound))
errorgroup = "CRDB"
errorkey = "CANTDELETE"
When I close the message, the save button is enabled, but the record status fields still show active. If I click on save, the record is saved in the database and UI is updated. Both the table and the table details now show record status inactive.
I need some indication to the user that the field was updated and the record needs to be saved.
I add MboSet().save() before showing the message. So when I close the message, the save button is disabled, but only the record status field in table details gets updated. The table column for record status still says active. If I refresh the search parameters then the field in the table gets updated.
mbo.setValue("RECSTATUS","Inactive");
logger.debug("NOT Allowed to Delete - itemsFound = "+str(itemsFound))
mbo.getThisMboSet().save()
errorgroup = "CRDB"
errorkey = "CANTDELETE"
What am I doing wrong? Is there a better way to get this done?
------------------------------
Luiz Robertto Mello
------------------------------
#AssetandFacilitiesManagement#MaximoIntegrationandScripting#Maximo