Question
· Feb 1, 2023

Error while calling a Operation in Foreach Loops

Hello guys,

i try to call a Operation within 3 foreach loops. 

When i try to do this, i always get the following error: 

I dont get any Errpr when i log my request message at this time i want to call a operation. 

Everything works and i get no error. But when i try to call the operation i get this error.

Then i tried to call a operation in the first Level (not in a ForeachLoop) it works. 

I simply call the operation with the RequestMessage from my Service.

 

When i now try to copy this call into the third Level (within 3 foreachloops) Then i also get this error.

I dont know what i am doing wrong...

 

Here is the BPL: 

XData BPL [ XMLNamespace = "http://www.intersystems.com/bpl]
{
<process language='objectscript' request='SESRequestMessage.rqmAddressToOpenOrdering' response='SESResponseMessage.rpmGenericResponse' height='2000' width='2000' >
<context>
<property name='allOrgaElementsFromAddress' type='%Library.ListOfDataTypes' collection='list' instantiate='0' />
<property name='OrgaElementitem' type='%String' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='allChildOrgaElementWithParent' type='%Library.ListOfDataTypes' collection='list' instantiate='0' />
<property name='OrgaElementChildItem' type='%String' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='allAddressTypesFromOneOrgaElement' type='%Library.ListOfDataTypes' collection='list' instantiate='0' />
<property name='orgaElementTypeIterator' type='%String' instantiate='0' >
<parameters>
<parameter name='MAXLEN'  value='50' />
</parameters>
</property>
<property name='rqmJSONDataToSend' type='SESRequestMessage.rqmJSONData' instantiate='0' />
<property name='myResponseFromOO' type='SESResponseMessage.rpmGenericResponse' instantiate='0' />
<property name='respListOfResponses' type='%Library.ListOfDataTypes' collection='list' instantiate='0' />
</context>
<sequence xend='200' yend='700' >
<if name='wenn AddressId is filled' condition='request.AddressId &apos;= ""' xpos='200' ypos='250' xend='200' yend='600' >
<true>
<assign name="getAllORgaElementsFromAddress" property="context.allOrgaElementsFromAddressvalue="##class(SESTransformationTools.prcAddressToOpenOrdering).GetOrgaElements(request.AddressId, 1)action="set" xpos='470' ypos='400' />
<foreach name='go through all Items' property='context.allOrgaElementsFromAddresskey='context.OrgaElementitemxpos='470' ypos='500' xend='200' yend='450' >
<assign name="Hole alle Kinder und Bilde einen Array mit allen OrgaElementIds" property="context.allChildOrgaElementWithParentvalue="##class(SESTransformationTools.prcAddressToOpenOrdering).GetOrgaElementChildsFromParent(context.allOrgaElementsFromAddress.GetAt(context.OrgaElementitem))action="set" xpos='200' ypos='250' />
<foreach name='Gehe durch jedes Kinderelement des OrgaElements' property='context.allChildOrgaElementWithParentkey='context.OrgaElementChildItemxpos='200' ypos='350' xend='200' yend='450' >
<assign name="hole alle Addressen des OrgaElements über den Addresstyp" property="context.allAddressTypesFromOneOrgaElementvalue="##class(SESTransformationTools.prcAddressToOpenOrdering).getAllAddressFromAddressType(context.allChildOrgaElementWithParent.GetAt(context.OrgaElementChildItem), 1)action="set" xpos='200' ypos='250' />
<foreach name='gehe durch jedes AddressElement des OrgaELementTyps' property='context.allAddressTypesFromOneOrgaElementkey='context.orgaElementTypeIteratorxpos='200' ypos='350' xend='217' yend='665' >
<assign name="Build Json for OpenOrdering" property="context.rqmJSONDataToSend.JSONStringvalue="##class(SESTransformationTools.prcAddressToOpenOrdering).buildJSONForOpenOrdering(context.allAddressTypesFromOneOrgaElement.GetAt(context.orgaElementTypeIterator))action="set" xpos='200' ypos='250' />
<call name='schicke den JSON an OpenOrderingx 22' target='opeXML' async='0' xpos='200' ypos='350' >
<request type='SESRequestMessage.rqmAddressToOpenOrdering>
<assign property="callrequestvalue="requestaction="set" />
</request>
<response type='SESResponseMessage.rpmGenericResponse>
<assign property="context.myResponseFromOOvalue="callresponseaction="set" />
</response>
</call>
<call name='schicke den JSON an OpenOrdering' target='opeAddressToOpenOrdering' async='0' xpos='203' ypos='511' disabled="true">
<request type='SESRequestMessage.rqmJSONData>
<assign property="callrequestvalue="context.rqmJSONDataToSendaction="set" />
</request>
<response type='SESResponseMessage.rpmGenericResponse>
<assign property="context.myResponseFromOOvalue="callresponseaction="set" />
</response>
</call>
</foreach>
</foreach>
</foreach>
</true>
<false>
<alert value='"Koi AddressId gfonda"' xpos='200' ypos='400' />
</false>
</if>
</sequence>
</process>

 

 

Maybe you can help me :)

P.S. Sorry 4 my bad english skills :)

Product version: IRIS 2022.2
Discussion (2)2
Log in or sign up to continue

I suspect the problem is that you're using a %DynamicObject. BPLs should use persistent/persistable objects because business process execution can in some cases be suspended temporarily and then resumed. Before execution is suspended, context objects are saved into the DB.

%DynamicObjects are not persistent objects, so their values are lost when execution is suspended. You can overcome this by using %ToJSON to serialize the %DynamicObject into a stream property of the context object. Streams are persistable.

The life cycle of a business process requires it to have certain state information saved to disk and restored from disk, whenever the business process suspends or resumes execution. This feature is especially important for long-running business processes, which may take days or weeks to complete.