Hi I have 2 datatables as shown as above, I want to compare the 2 dts and return the following result so I can update the employee list in HR system.
To remove: Employee 5, Employee 6
To add: Employee 7
You can use join Datatable activity here with inner join
- Inner - Keep all rows from DataTable1 and DataTable2 which meet the Join rule. Any rows that do not meet the rule are removed from the resulting table.
newEmployeeList = New List(Of String)(newDataTable.AsEnumerable().Select(Function(row) row("Employee").ToString())),
currentEmployeeList = New List(Of String)(currentDataTable.AsEnumerable().Select(Function(row) row("Employee").ToString())),
employeesToRemove = currentEmployeeList.Except(newEmployeeList).ToList(),
employeesToAdd = newEmployeeList.Except(currentEmployeeList).ToList(),
employeesToRemoveString = String.Join(", ", employeesToRemove),
employeesToAddString = String.Join(", ", employeesToAdd),
outputMessage = "To remove: " & employeesToRemoveString & Environment.NewLine & "To add: " & employeesToAddString
Thanks & Cheers!!!
Refer this video as per this suggestion
thanks for the code,
How do I convert this employeesToRemoveString and employeesToAddString to a dt so that I can loop the dt and do the updating in hr system (remove or add the employee).
Kartheek, would appreciate if you could help on the initialization part
Hi, i cant download the doc due to org’s policy. do you mind if u can share the code here instead? thanks
Just try this one
First use the left join in the join data table it keeps all the data in the first dt and keep the matched values in the both dt.
so its return like this
and use the output of the join dt in the for each dt and use assign activity
so final result like this
hope it will work.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.