Condition For Record With Single Line Or Multi Line

Hi There,

I have a data model with records “on change” of a field. So some records have 1 line others have more then 1 line. How can I make a condition to separate the two?

What do you mean when you say you want to separate the two?

Do you mean you want all the 1 line records go to create one document and all the 2+ line records to go create a second document?

Yes I’m hoping for a multiple conditions step so there I can handle the records with one line in a centrain way and the records with 2 lines in an other certain way. etc

There’s two ways this could go.

  1. You always treat the first row the same, regardless of the total number of lines

  2. Row one is treated completely differently if there is only one line compared to if there are more.

The first case is the simpler of the two. Let’s look at how that might go. First, you need to loop. This is simply going to loop through the entire data set.

Inside of that loop you’ll create your condition. It’s a pretty simple one. The left operand will be JavaScript based and contain the following line:

steps.currentPosition;

You can read more on this function here: PReS Connect 2018.1 User Guide

In short, it tells us where we are in the loop.

The right operand will be based on a value of 1. We’re just looking to see if steps.currentPosition == 1.

That’s basically it. Now you’d just put the rest of your logic in the right or left branch of that Condition. On line 1, X will happen. On all other lines, Y will happen.

Now, take example 2 above. You need to do something very similar, but you essentially have to loop twice. Why? You need to first determine if there is more than 1 line, then you need to go back and actually do your extractions. We can’t reuse the same extractions for the first line in the two cases as they’re both expected to be treated differently.

That’s going to look something like this:

So what’s going on here? Well, the first extract is creating an empty field ‘lineCount’. Then we loop through the entire data set with the first repeat. In that repeat is an action with the following code:

record.fields.lineCount = steps.currentPosition;

Every loop through, the current loop counter is stored in lineCount. So by the end of that loop, we know exactly how many lines there are.

So far, so good.

Next, outside of the first repeat is another GoTo. This sends us back up to the Top of the Record as we’re essentially starting over at this point.

Finally, we get to our condition. There’s nothing fancy here. Again we’re just looking to see if lineCount equals 1. If it does, we go left and deal with our single line however we need to. If it does not, we go right and can begin looping through the multiple lines we have.

Wauw thank you, this is very helpfull I’m going to check this out

Works Like A Charm Thank You Very Much. I Like The Option Best!