Logic build by using filter data table between two data tables

  1. Login Data Table:
  • Columns: “key” and “person name”
  • Example rows:
  • “key”: “[rpa,UiPath]”, “person name”: “john” (John has access to both RPA and UiPath)
    • “key”: “UiPath”, “person name”: “rsj” (RSJ has access only to UiPath)
    • “key”: “rpa”, “person name”: “loki” (Loki has access only to RPA)
  1. Jobs Data Table:
  • Columns: “key” and “job name”
  • Example rows:
    • “key”: “rpa”, “job name”: “accenture” (A job related to RPA at Accenture)
    • “key”: “UiPath”, “job name”: “tcs” (A job related to UiPath at TCS)
    • “key”: “datascience”, “job name”: “tcs” (A job related to Data Science at TCS)

You need to filter the jobs data table based on the keys associated with each person in the login data table. For example:

  • For “john”, you need to filter jobs containing “RPA” and “UiPath” keys.
  • For “rsj”, you need to filter jobs containing only “UiPath” key.
  • For “loki”, you need to filter jobs containing only “RPA” key.

You want to implement this filtering process in UiPath.and for each login filter job

Hey @LOHITH_KUMAR_SAKA

I think you can try something like this vb.net code:

Dim aggregatedResults As New DataTable
If JobsDT.Rows.Count > 0 Then
    aggregatedResults = JobsDT.Clone()
End If

For Each loginRow As DataRow In LoginDT.Rows
    Dim keys As List(Of String) = New List(Of String)
    If loginRow("key").ToString().Contains("[") Then
        keys = loginRow("key").ToString().Trim(New Char() {"[", "]"}).Split(New Char() {","}, StringSplitOptions.RemoveEmptyEntries).Select(Function(k) k.Trim()).ToList()
    Else
        keys.Add(loginRow("key").ToString().Trim())
    End If

    Dim filteredRows = JobsDT.AsEnumerable().Where(Function(job) keys.Any(Function(key) job("key").ToString().Trim().Equals(key, StringComparison.InvariantCultureIgnoreCase))).ToList()

    If filteredRows.Any() Then
        For Each jobRow In filteredRows
            Dim newRow = aggregatedResults.NewRow()
            newRow.ItemArray = jobRow.ItemArray
            aggregatedResults.Rows.Add(newRow)
        Next
    End If
Next