Can not loop in a list that have 1 item

Hi all experts

If any boby have ever met this problem, please share for me your solution

I use a loop to insert each item in a document list to database.when number of item in document list > 1, it work well, but when number of item in document list = 1, Loop does not work. Please see detail at attachment

Thanks for all your help
loop.doc (36 KB)

What does not work? From your attachment, the flow is recognizing that PkgItem has contents. Do you mean that the steps below your Loop are not executing? If so, what are those steps?

Hi PhilLeary,
Thanks for your reply
Yes, the step below my Loop did not work when PkgItem has only 1 item, when PgkItem has more than 1 item, all step below my Loop was executed normaly! Those service below my Loop is Map funtion from PkgItem to database. With those information, can you help me?


How are you getting document (the parent of PkgList)? It would appear that this is where the problem lies. As long as Loop sees a documentList type for PkgItem, it won’t care whether it has one item or more. However, if it does not see a documentList type for PkgItem, that could be a problem.

If you are creating document from something like xmlNodeToDocument, be sure to set the “arrays” input variable to PkgItem.

It looks like you are not generating your document right, loop is working as it is supposed to. As mentioned by Phil check if you are setting the “arrays” input while using xmlNodeToDcument service(which I believe you are using) or use the documentType input(set “makeArrays” false) if you already have the instance of PkgList document.

Thanks PhilLeary and Talha Khan,

As your help, in xmlNodeToDocument service, i set value"PkgItem" for Input Parameters “arrays”, It OKs.

Thanks and best regards


An alternative to using the arrays parameter is to use the documentTypeName parameter. Please take a look at the Built-In Services Reference Guide.

I personally prefer this approach because you don’t have to specify each element that must be generated as a list. All details regarding the document structure are stored in the document itself.

  • Percio