How to execute just 1 time the for each row based on comparing the first "for each" value with the second "For each"

Hello guys.
Updated:

(CurrentRow(“Nombres”).ToString).Contains((CurrentRow1(“Nombres”).toString).substring(5))
** false**
**I’m using this method but it returns false in this section of the second for each **
image

I don’t know why , is this a good way?. thanks.

I’m struggling with this problem.

The desired workflow is that the second “For each Row in Data Table” just runs once when its value ( CurrentRow) has some part similar to CurrentRow1.

For example:

CurrentRow1 hast “Banco BCI” , BCI is the desired value because CurrentRow value has “Planillas_Bco*Bci*20”

image

Wrong workflow:
It’s not working well because the second “For each Row in Data Table” works with all the values and then execute the first “For each Row in Data Table”

Any idea or re-do this method ?? Please.

I’m attaching the files.
Nómina.xlsx (8.6 KB)

Main.xaml (11.7 KB)
test.xaml (4.3 KB)

This could be due to case sensitivity.
Try using ToLower or ToUpper method in addition to Contains
For example:
VariableName.ToUpper.Contains(“TEST”)
or
VariableName.ToLower.Contains(“TEST”), in your case replace “TEST” string with currentRow value

1 Like

Hello @pprin001,
" (CurrentRow(“Nombres”).ToString).Contains((CurrentRow1(“Nombres”).toString).substring(5))"
CurrentRow(“Nombres”).ToString = “Planillas_BcoBci20"
CurrentRow1(“Nombres”).toString = "Banco BCI”

Reference - Str1.Contains(Str2)
The expected output for the above code snippet is False, because the .Contains method checks if the entire string “Str2” occurs within “Str2”. I guess you are assuming it would also be checking if all the possible substrings of “Str2” will also be checked. But that is not how the .Contains method works. It will just check if “Banco BCI” occurs within “Planillas_BcoBci20”. It doesn’t check if the substring “BCI” occurs within “Planillas_BcoBci20”. Refer to code examples at String.Contains Method (System) | Microsoft Learn

One of the possible solutions for your problem would be to write a program to find the length of the longest common substring between str1 and str2 and use the code within UiPath (Invoke Code activity).

You have mentioned in your query that “The desired workflow is that the second “For each Row in Data Table” just runs once when its value ( CurrentRow) has some part similar to CurrentRow1.” You need to clearly define what some part means. What is the minimum length that should be common between the 2 strings for the output to be True? Once that is decided upon, you can check if the output of the above program meets the minimum length.

Hope the above explanation is clear. Please let me know if you have any further queries.

P.S. Kindly mark this reply as the solution if it helps in resolving your issue.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.