Switch case solution

AH: Purchased
AU: balance
AW: Natural/Declared Disaster
B: Payments
M: grantors request
S: Contact lender for info

The above information i need to be save in Config file

From the database datatable I will get Id’s { AH.AU,AW,B,M,S}

By using switch case i need to Process that particular ID

Hi @ManjunathReddy

Use Switch Case activity

Hi @ManjunathReddy

  1. Read the Config file into a DataTable using the “Read Range” or “Read CSV” activity in UiPath.
  2. Use a Switch activity to process each ID:
  • Set the Expression to the ID value from the database (e.g., “AH”, “AU”, etc.).
  • For each case in the Switch activity, use the DataTable.Select method to filter the DataTable based on the ID and retrieve the corresponding Description.
Read Range (Excel Application Scope) -> Output: dtConfig

Switch (Switch activity with Expression set to ID from the database)
    Case "AH"
        Assign: description = dtConfig.Select("ID = 'AH'")(0)("Description").ToString()
    Case "AU"
        Assign: description = dtConfig.Select("ID = 'AU'")(0)("Description").ToString()
    Case "AW"
        Assign: description = dtConfig.Select("ID = 'AW'")(0)("Description").ToString()
    Case "B"
        Assign: description = dtConfig.Select("ID = 'B'")(0)("Description").ToString()
    Case "M"
        Assign: description = dtConfig.Select("ID = 'M'")(0)("Description").ToString()
    Case "S"
        Assign: description = dtConfig.Select("ID = 'S'")(0)("Description").ToString()
    Default
        Assign: description = "Description not found"
End Switch

Hope it helps!!

Hi @ManjunathReddy

  1. Use For Each Row activity to loop through each row in the database DataTable.
  2. Assign: currentID = row("ID").ToString()
  3. Use a switch activity to match the ID from the database DataTable with the corresponding value in the Config DataTable.
    Set the Expression property of the switch activity to currentID
    Case “AH”:
    • Process “Purchased”
      Case “AU”:
    • Process “balance”
      Case “AW”:
    • Process “Natural/Declared Disaster”
      Case “B”:
    • Process “Payments”
      Case “M”:
    • Process “grantors request”
      Case “S”:
    • Process “Contact lender for info”

You don’t have to do this. Just put row(“ID”).ToString into the Switch. Creating a variable to duplicate the ID is extra work for no reason.