cancel
Showing results for 
Search instead for 
Did you mean: 

How to break out of a repeater loop when a condition is met?

Former Member
0 Kudos

Hi,

XMII Version: 11.5

I am trying to break out of a reapeater loop in a BLS Transaction when a condition is met. This works fine if the condition is initially true but does not seem to work if the condition starts out false and turns true after a few repetitions of the repeater loop. Instead, it loops until the maxIterations is met and then breaks out.

Below is the condition I am using in the break link of the repeater loop.

if( (stringindexof( Local.strTempParam1 , "<THOUSANDITEMTAG>" ) == 0), true, false)

I've used a trace block right below the repeater loop with the same condition and have watched it change from false to true, and the repeater loop continues to repeat. I put an if block right below the repeater with the same logic and that keeps the transaction from repeating when it shouldn't, but this seems inefficient.

Is there any way to actually make it break out when it is supposed to?

Thanks alot for any help or clarifications.

Kerby

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Simply set the value of the boolean "Break" property on the repeater action to "true" to interrupt the processing of the repeater loop.

Rick

Former Member
0 Kudos

Thanks Rick, that solved my problem

To expand on this a little, I had to set the break property of the while loop to "true" in a different action block than the loop itself. When I was trying to set the break to true inside the while block via a if statement, it did not take effect. It seemed like the initial break condition of the block was only evaluated the first time the while block was entered and not on each subsequent loop.

Paol,

Setting the currentItem to maxIterations or greater than maxIterations also did not seem to work. This was something else I had tried early on.

I guess I just missed the obvious way to break out after I couldn't get the break condition to work in the loop itself.

Thanks.

Kerby

Former Member
0 Kudos

That's correct, Kerby. Actually, the repeater action effectively only ever runs "once", before the first iteration of the loop.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi.

I am not sure, but as I remember, you are able to set the loop parameter, i.e. the count parameter on the loop action to the max value and thereby abort the repeater.

BR.

Poul.