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

Home > Problem with inserting objects into a list in a business production

Question
Guy Peer · Aug 28, 2017

Problem with inserting objects into a list in a business production

Hi,

I have a process in which i call a rest operation in a while loop, get a response in JSON format of 50 issues, with paging, meaning this call will happen until the total amount of issues will be returned. each JSON is parsed into a proxyObject, and inserted to a list. later the entire list will be sent to an SQL operation which will write the data in the appropriate tables.

The problem i'm encountering, is when i use the "ASSIGN" action, with insert at a certain key (context.i=context.i +1  for each iteration of the loop), i get an Error  that says that the value 3 is invalid key.

i've switched to "Append" and that error goes away, but in the operation when i iterrate through the object i get an invalid oref error.

set CountMain = pObject.IssuesList.Count()
for i=1:1:CountMain
{
       set CountRow=pObject.IssuesList.GetAt(i).Count()
       for j=1:1:CountRow
       {
             bla bla bla
       }
​}

i get INVALID OREF on set CountRow.

after a quick investigation I've found that  somehow i have more then one list.

if i set the loop to run twice, i have to object references of the list, so that's why value 3 is invalid because it's trying to set it at a position higher then plus one from the last full position.

Also noticed, that every time I go out of the scope of ENSEMBLE to an external class (NOT A SERVICE PROCESS OR AN OPERATION) all the context vars are some how reseted or get a new instance. 

what am I doing wrong? or for that matter is there a workaround for my issue?

Thank you,

Guy Peer

#Business Operation #Business Process (BPL) #Object Data Model #Ensemble

Source URL:https://community.intersystems.com/post/problem-inserting-objects-list-business-production