Using conditions with loops

Hi everyone, I’m new to RPA Express and was wondering what are the ways to tackle my work, I had tried “if-else” and “for each” conditions, with both outcomes not what I wanted. So here goes…

I have a list of charges to bill customer, which is not fixed for every invoice. For e.g.

How do I make sure the actions are only performed if Chrg is not empty or not zero?

Thanks in advance for your help! :smiley:

Hi @Jingle I think a script like this should work in your case

It checks that the 3rd element in each row is not empty and is not equal to 0.

Hi @ashapkina Thank you for your prompt reply. However, the result is not what I wanted.

image

Btw, What difference does it makes if I key “element” instead of “element[3]”?

What exactly do you need to do with the data?
Perhaps, the issue is not with the condition, but with the actions you have in the loop.

{element[3]} points to the 3rd item in the list variable ${element}.
You can read about indexes here: https://kb.workfusion.com/display/RPAe/Recorder+Variables#RecorderVariables-GettingValuefromListsandTables

I need to copy each charges to my company billing system whereby each charges will have their own line as the name of the charges will be different. Hope it clarifies!

1 Like

Then I guess the example above should work.
Check out this video tutorial - https://youtu.be/-_BFTGtz3_g
the logic of it is pretty similar to your case.

Hope it helps :grinning:

Thanks Ashapkina! I managed to get the result I wanted. :smiley:

1 Like

Hi @ashapkina I tried it in my billing system and the result I’m getting is with comma ( , , , 100 ,)

How can I make sure it only paste the value that is not empty without bracket or comma. My script is as follow, can’t figure out what went wrong. If I’m pasting it to excel, it will work.

I think you need to use another variable in this action: ${element} instead of ${charges}.

Made the necessary changes and able to get the result I wanted. Thank you for your prompt help as usual!

Just one more problem, if I use get row from excel, I won’t be able to use for each {element[3]}, error executing this action.

Yes, of course. If you use For Each with a List, you cannot use an Index there as ${element} will be a string.

Is there another way to do it? Because in my case, each row has their individual invoice number where charges will be created respectively. By getting range, it will just copy every charges from other companies.

I’m not sure I understand the issue. If you have the code as above and use ${element} in the Enter Keystrokes action, it will only type the value from the 1st cell of the row. So, for each company, it will type different values.
Do you need it to do something different?

I’m actually doing a loop for each row, meaning to say one row for one invoice. So I will have to use “get row” instead of “get range”.