Question
· Jun 3, 2021

How to remove a business host programmatically from a running production?

Hi guys,

How can we remove a business host from a running production?

I've read and tested how to add it to a production, while when I try to remove it from the production with the following codes:

 

   

Set tSC = $$$OK
    Set prodName = "CDRDemo.DemoProduction"
    Set confName = "TEST1"
    Set className = "Demo.LISClient.Operation.PatientOperation"
    #Dim prodConf As Ens.Config.Production = ##class(Ens.Config.Production).%OpenId(prodName)
    Set itemId = ""
    &SQL(Select ID into :itemId from Ens_Config.Item
        where Production=:prodName
        and ClassName=:className
        and Name=:confName)
    Set confItem = ##Class(Ens.Config.Item).%OpenId(itemId)
    Do prodConf.RemoveItem(confItem)
    Set tSC = ##class(Ens.Director).UpdateProduction()
    Quit:$$$ISERR(tSC) tSC
    Quit tSC

The execution is successful, but when I then visit the production page, it shows:

 

Aslo, the business host reference is still in production class, then how may I remove it programmatically and keep the production runnning?

Product version: IRIS 2020.1
Discussion (1)1
Log in or sign up to continue

Oh, missed one line of code.

Set confItem = ##Class(Ens.Config.Item).%OpenId(itemId)
    Do prodConf.RemoveItem(confItem)
    Set tSC = ##class(EnsPortal.Template.prodConfigSCPage).CallProductionUpdateAndSaveToClass(prodConf,"","SaveProduction")
    Quit:$$$ISERR(tSC) tSC  
    Set tSC = ##class(Ens.Director).UpdateProduction()
    Quit:$$$ISERR(tSC) tSC
    Quit tSC

Just add 

Set tSC = ##class(EnsPortal.Template.prodConfigSCPage).CallProductionUpdateAndSaveToClass(prodConf,"","SaveProduction")

Now it's working