How to do if any Column missing error

hi all,

Please help me for below
if any column missing/ or data type wrong in excel sheet then that particular mail Auto send to that user
thanks in advance
Regards,
Ram Gurav

@Ram_Gurav1 can you show me excel sheet

Hello @Ram_Gurav1
Try the following Steps

  1. Download the excel sheet from the mail.
  2. Read the Excel sheet
  3. Use Flow decision or IF conditions
    3.1 If you Know column count, use it for example 5 columns “DT.Columns.Count=5”, if 5 columns are present it will process the next step, Else you can send the mail to sender with specific messages
    3.2. Otherwise use the lookup data table and search for desired value in DT, if the value presents it shows the index number else, it will results “-1”, Based on it you can frame condition like Not LookuValue=-1, same an above flow for then and else.
    image

Hello @Ram_Gurav1 ,

In config file (under settings or assets) store required column names as
PreDefined_ColumnNames = A,B,C,D.

Use a Try-Catch block.

  • In try block :

PreDefined_ColumnNames | data type = List Of String
Assign

PreDefined_ColumnNames = Config(“PreDefined_ColumnNames”).ToString.Split(","c).ToList()

Use a for loop to loop through the items of PreDefined_ColumnNames

BoolVal = DataTable.Columns.Cast(Of DataColumn).Select(Function(x) x.ColumnName).ToArray().Contains(item)

Where item is a predefined column name (used from for loop)

Create a variable UnMatched_ColumnNames | data type = String
Assign

UnMatched_ColumnNames = If(BoolVal,Nothing, UnMatched_ColumnNames+“,”+item )

Outside for loop

If(String.IsNullOrEmpty(UnMatched_ColumnNames))

Use send Mail message activity and send email for UnMatched Column Names

  • In catch block
    Catch the exception for dataType mis-match or other errors and send exception email

Regards,
Rohith