Above screen captured using Table Extraction activity and stored in to DT
We need to match name value stored in above DT with below Mapping Table DT and get the Email Address.
For Example : Erika Majszin available in above website and we need to match with below mapping table and get the email address stored in below table. Please suggest
1 Like
postwick
(Paul Ostwick)
September 2, 2023, 1:54pm
2
This is a standard database operation called a join. Use the Join Data Table activity.
A quick solution would be:
1- Create a for each that loops the number of columns that your first datatable has. (for each: Enumerable.Range(0,YourFirstDatatable.columns.count).ToArray()
2- Use the index of the loop to get the names: CurrentName = row(0)(index)
3- Within the loop use a select to find the name in the second datatable: MatchedRows = YourSecondDatatable.Select(āName= 'ā+CurrentName+āāāā)
4- Get the email for the current name: emailAddress= MatchedRows(0)(āEmail addressā)
Hope this helps.
Hi
We can do this simply with a lookup datatable activity
Have a view on this doc for more detail
The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...
Or if u would like to go expressions then this thread looks suitable for ur scenario
Hi @aishwarya1
u can try this
assume
dt1 ā> sheet1
dt2 -----> sheet2
dt3_uncommon= (From r1 in dt2.AsEnumerable
Where dt1.AsEnumerable().Where(Function(row) row(āOrganization Nameā).ToString.Trim.Equals(r1(āOrganization Nameā).ToString)).Count=0
Select r1).CopyToDataTable
Now use append range or merge datatable to merge the dt1 and dt3_uncommon to a excel sheet.
Regards,
Nived N
Cheers @Sathish_Kumar_S
1 Like
postwick
(Paul Ostwick)
September 2, 2023, 3:48pm
5
You can do this with a single Join Data Table activity.
2- Use the index of the loop to get the names: CurrentName = row(0)(index) - But there is NO fixed index number for Name column in FIRST Data table ⦠how to handle this?
Itās because you need to use a āfor eachā not a āfor each rowā
slopezchavez:
2- Use the index of the loop to get the names: CurrentName = row(0)(index)
3- Within the loop use a select to find the name in the second datatable: MatchedRows = YourSecondDatatable.Select(āName= 'ā+CurrentName+āāāā)
4- Get the email for the current name: emailAddress= MatchedRows(0)(āEmail addressā)
Yes now i have changed to For each activity now
2- Use the index of the loop to get the names: CurrentName = row(0)(index) - What will be variable type for this?
And the i canāt use always same index number as the name value will be in any index in First DT
Tried 2 index umber for testing and getting below error
@Sathish_Kumar_S
Make the below datatable2 to dictionary
Dict_values=Dt.Asenumnerable.todictionary(Function(x) x(0).tostring,function(r)r(1).ToString)
Use for each row in datatable for datatable 1
Inside use
Assign
strEmailaddress=dict_values(currentrow(āApp3ā).tostring)
StrEmailaddress is the variable and you will get the output as
Erika@gmail.com
Cheers
Thank you for you response @Shiva_Nikhil
strEmailaddress=dict_values(currentrow(āApp3ā).tostring) ā But name will not be always in App3 column⦠it will keep change
@Sathish_Kumar_S
No problem
Just replace the columnname at the app3
You will get the same results beacuse the values in the dictionary as constant
But we wouldnāt the exact column name
@Sathish_Kumar_S
If you know the name
Then take one assign and directly pass that name no need for each row in datatable activity
StrEmailaddress=dict_values(āErika Majsanā).tostring
If you want to find is there are not then use below gives boolean output
Dt.rows(0).itemarray.any(function(x) x.tostring.contains(āErika Majsanā))
Fine
Hope the below steps would help you resolve this
Letās take the first datatable is dt_1
Second one is named as dt_2
use a assign activity like this
arr_input = dt_1.Rows(0).ItemArray
This will give the first row as array which will hold the name we want to search
arr_input is a variable of type array of string
Now use a FOR EACH ROW activity and pass the second datatable as input
Inside the loop use a IF condition like this
arr_input.Contains(CurrentRow(0).ToString)
If true then goes to THEN block where u can get the mail id like this with a assign activity
str_mailid = CurrentRow(1).ToString
Followed by this assign activity in THEN block use a BREAK activity to stop the loop
If the condition is false then it continues with ELSE Block and goes further
Cheers @Sathish_Kumar_S
1 Like
We donāt know the name also ⦠because each queue transaction will have different buyer names
Thatās why with the above mentioned steps u donāt need to worry about the column position or even the Name value and position
It will just compare and get the value without using index position or even the column name
Check the last post and let us know the outcome
@Sathish_Kumar_S
@Sathish_Kumar_S
use for each row in datatable for second datatable
if activity
datatable1.rows(0).itemarray.any(function(x) x.tostring.contains(currentrow(0).tostring))
then
assign strEmailaddress=currentrow(1).tostring
else
no activity need in else part
cheers
1 Like
system
(system)
Closed
September 6, 2023, 5:59am
19
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.