Published on InterSystems Developer Community (https://community.intersystems.com)

Home > How to delete an item from a production by code?

Question
Kurro Lopez · May 22, 2019

How to delete an item from a production by code?

Hi all,

I am trying to delete an item from a production through a routine that installs and disables items.

To add any item, I have no problems, even to enable and disable some particular items.

The problem arises when I try to eliminate the production item, because when it does, the production become unstable and only works again when this item is added again in the collection (or the item is deleted manually in the production.cls)

 

This is my code attempt:

set productionName = "MyApp.production"

set itemDelete="MyApp.BP.item"

if ##class(Ens.Config.Item).NameExists(produccionName,itemDelete, .idItem)
{
    write !,"Removing BP: "_itemDelete
    set objItem=##class(Ens.Config.Item).%OpenId(idItem)
    do objItem.%Delete()
    kill objItem

    do ##class(Ens.Director).RestartProduction(0,1)
}


In the best case, it does do nothing and the item is maintained. I have also tried using the %DeleteId() method directly and some functions of the Ens.Config.Production class such as RemoveItem

Any ideas?

 

Best regards,

Francisco López

#Ensemble #InterSystems IRIS

Source URL:https://community.intersystems.com/post/how-delete-item-production-code