Increasing the value of a flow variable +1

Andrew105
Kilo Contributor

Hello everyone,

I am currently working on a flow in the flow designer and my flow looks as follows:
find_real_file.png

In my loop, I would like to run the following options until the flow variable 'position' (defined on step 2 as an integer = 0) is equal to a value defined in the loop, essentially mimicking your regular for loop. Therefore, I would like to increase the value of position +1 on step 19. Is there a way to do this in flow designer or even using a script for the value of the flow variable? If not what would be a good alternative to this method?

1 ACCEPTED SOLUTION

Hi Andrew,

I upgraded my PDI to Rome. Not sure whether it is added to Rome. There is an alternate way :). You can use inline script.

Below code can be used in the inline script. This takes the flow variable position and increment by 1.

var data = fd_data.flow_var.position + 1;
return data;
 
You need to click the inline script icon available next to the text box to add script. Refer the below screenshot:
find_real_file.png
Thank you,
Palani

View solution in original post

7 REPLIES 7

palanikumar
Mega Sage

Hi Andrew,

Your flow designer image is not visible. Can you send again

Thank you,

Palani

Thank you,
Palani

Hi Palani,

You should be able to see it now, thanks for letting me know.

Andrew

Hi Andrew,

There is an out of box option available in Flow. You can follow these steps:

1) In Set Flow Variable step drag and drop flow variables from Data tab.

2) If you move your mouse over the variable, you will see +fx button visible. Refer below image. Click on it

find_real_file.png

3) You will see options menu

4) Select Math > Add

5) Specify the Number with 1 and click Apply. Note: Apply button may be disabled. After entering value in Number text box, press tab key. This button is visible only after that. Refer image below

6) You will not get confirmation message after adding. To confirm that the transforms is added, refer the applied transforms section (Refer the 3rd image where it is highlighted)

Note: If you add multiple times, then the transform will be applied multiple time and the number is incremented multiple times. Make sure you see only one entry applied transforms

7) Now the counter is added. 

 

find_real_file.png

find_real_file.png

Thank you,
Palani

Hi Palani,

Thanks for showing me this, I didn't notice this. However I am still running into a problem. When I got to the 'Math' section, I do not see the 'Add' option. It almost seems to be acting as though my flow variable is an array when it is clearly an integer.
find_real_file.png

find_real_file.png

Any insight into why this might be happening?

 

Thanks,

Andrew O'Connor