Index needed when referencing variables in a list?

Does anyone know of an issue when upgrading from 4.x to 6.x that requires you to reference documents in a document list using the element index?

I have a service in 4.6 that branches on a field in a document (in a document list) and references the field as ‘/documentListName/fieldName’.

Once this code was placed in a 6.5 IS and I attempted to execute it, the branch statements always resolve to the $null sequence. After steping through the code, I noticed the data in the pipeline is named ‘/documentListName/documentName[index]/fieldName’ and the branch statement is not able to locate ‘/documentListName/fieldName’.

I digged into this issue deeper and stepped through the original code on a 4.6 IS and noticed the data in the pipeline has always been named ‘/documentListName/documentName[index]/fieldName’ and works as expected. If there are no documents in the document list, I would like to execute the $null sequence option - otherwise, execute the $default option.

Was a change made to the way variables should be referenced somewhere between the 4.6 and 6.5 releases?

I hope I understand your question clearly… So… you have a document list, which may or may not have documents in it. Each of these cases, you want to deal with differently. What you can do is to use ‘pub.list:sizeOfList’ to check if the documentList has any child nodes or is empty. If the result of ‘sizeOfList’ is ‘0’ (zero), you can execute the null sequence, else, you can call the branch on the document/variable.

I don’t know if it happens in the scenario you are working on, but, you might want to consider a null value for the documentList.

HTH, Rohit

Hello,
If you only did a branch before, you may want to loop over the document with the branch inside. That want you don’t have to worry of implicit indexing. You can also branch on the $iteration field that available to only operate on certain elements.

Other than that, use an explicit index if you only want operate on certain elements and never interact with others. Good day.

Yemi Bedu