Issue in Deleting Object via SDK
While trying to delete one of the item via SDK OR UI, i am getting the below error :
“Can not delete item: This item is a BOM component of at least one item”
This WARNING is “APDM_DELETECOMPINUSE_WARNING” which comes where the object is in use.
In order to handle this i tried disabling the Warning and then deleting and then tried to enable it back. But it didn’t work. Tried API recommendation and sample code but it didn’t work.
Posting the code below, Let me know if you see any issue with this or in case you have any alternate approach.
try {
objLogger.debug(“—Inside DeleteItem method—–“);
obj.delete();
objLogger.info(“Object deleted now”);
} catch (APIException e) {
try {
objLogger.info(“Receieved exception while deleting. “);
objLogger.error(e.getMessage());
objLogger.error(e.getErrorCode());
if (e.getErrorCode() == ExceptionConstants.APDM_DELETECOMPINUSE_WARNING) {
m_session
.disableWarning(ExceptionConstants.APDM_DELETECOMPINUSE_WARNING);
obj.delete();
m_session
.enableWarning(ExceptionConstants.APDM_DELETECOMPINUSE_WARNING);
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
objLogger.error(e.getMessage());
}
The logger captures 374 code as the error which is nothing but this exception only.
Looking forward for help.
Regards,
Arif
Hi Arif,
There is a Smart Rule that disallow by default to delete an item with BOM
19.2.13 Delete Instance With BOM
Settings: Allow, Disallow, Warning (default)
Should prevent accidental deletion of Instances, which already have a BOM, from the Instance tab. Deleting the Instance would lead to the loss of the Model relationship, including the Configuration Draft.
THis rule cannot be disabled by SDK so if you cannot disable the smart rule due to business reason, you have to remove BOM items before delete from sdk (item.getTable(BOM).clear();)