Question
· Aug 18

How to programmatically update a port number on multiple items.

Hello, I am total newbie when it comes to ObjectScript (just started going through the tutorial).  We have a task where we have to update the port number for 75-100 items (say for half of the items in our production).  Going through the documentation and other community posts it looks like we could utilize class method 'ApplySettings' in Ens.Production.  But we are running into an issue.  Below is what we currently have.  When we hard code the item, it works.  But, if we store the item in a variable and try it pass it through.  Then it doesn't work.  We are also not seeing an error.  Is our thought process valid or should be looking at it differently.  Can we pass a variable into pSettings list?  If so, how should our syntax be?

Step 1: Got a list of items by running a sql against Ens_Config.item to get the name and added to a file. (Each item is in a line by itself)

Step 2: Trying to run the class method below to read the file and loop through the values to update port number.

ClassMethod UpdatePort() As %String
{
set tUniqueFile = "/hs-connect/test/Jobs_To_Update.txt"
// Write the file from previous line to a stream
set tStream = ##class(%Library.FileCharacterStream).%New()
Set tSC=##class(Ens.Util.File).LinkFileStream(tUniqueFile,.tStream)
set tStream.Filename = tUniqueFile // Read the stream to gather the job values
if $$$ISERR(tSC) quit ;
    while 'tStream.AtEnd {
        set str=tStream.ReadLine()
        write !,"The Job Is: ",str
        
        //set pSettings("From_Source_Rec_Job","Adapter","FTPPort")=2022.  If we specify the job, then it works
        set pSettings(""_str_""),"Adapter","FTPPort")=2022  //If we try to pass the variable, it does not
do ##class(Ens.Production).ApplySettings("TST.Production", .pSettings)                
}
// Delete the file with the list of jobs
do ##class(%Library.File).Delete(tUniqueFile) write !
return tSC
}

Regards,

Raja

Discussion (3)1
Log in or sign up to continue