How to check if Document List is empty or not?

In Webmethods Developer, I have a Flow Service which there is a Dynamic SQL Adapter Service invoked. Let’s say the adapter service name is getData. It contains SELECT sql statement. Usually the output variable is automatically named getDataOutput. It has one document list sub-variable named “results”. So the long path is getDataOutput/results. As we know, the “getDataOutput/results” would contain the record data selected. If no record selected, it should be empty.

Now, I want to check if the “getDataOutput/results” is empty or not. I put a Branch below the “getData” service. If the “getDataOutput/results” is empty, it should enter the Branch. The Branch’s Evaluate Labels was set to True. Inside the Branch, there is a Sequence which its Label was set to !%getDataOutput/results%. The expresion should be clear that it was testing if getDataOutput/results is null.

However, when I executed the service, it didn’t step into the Branch at all when the “getData” service returned no record. So it turned out that the getDataOutput/results variable is never get null.

I had tried with using %getDataOutput/results/length% == 0 or %getDataOutput/results.length% == 0, but still no avail.

So, as the title said, how to check if Document List is empty or not? (without using Java Service if can)


I didn’t get the existence check of a variable in the label of a branch to work either, but putting the expression to test into the Switch field of the branch and just have bracnhes with $null and $default worked fine for me.



Hi bromo:

I’m agree with Mwroblinski, those expresions:

%getDataOutput/results/length% == 0 or %getDataOutput/results.length%

Don’t work you must to use a BRANCH evaluating %getDataOutput/results% with two options, one label equal $null and other $default :slight_smile:

hi all,

I tried, this doesn’t work too. It always ended up in $default whether %getDataOutput/results% is empty or not. The problem is %getDataOutput/results% is never be null, so the solution above will not work. For Document List, empty and null are two different things.

Logically, Document List is an array type, so I expected there is built-in property called length as in Java language to indicate the array is empty or not, but unfortunately there is none of it.

Did you have getDataOutput/results with the % as the switch variable while trying the above solution? You dont need to have the % symbols if you are using Switch variable in Branch. Try without it.

If that didnt work then try this instead; getDataOutput/results[0] as the switch variable of your branch. Note; no %. This will check for the existence of the first record in the result list.


Hi Suren,

It worked :eek:. Thanks very much :slight_smile: