For Each ROW with if condition - OBJECT REFERENCE NOT SET TO AN INSTANCE OF AN OBJECT

Hello There,

I am trying to use For each row activity with if condition. I want to find the letter ‘N’ in an excel column and based on the same define an ‘IF condition’. IF letter N existing than abort the workflow if the letter N does not exist in the specified column then I want the system to proceed with else condition.
Else Condition is to open an application that is saved on my desktop and perform certain steps.

The system is throwing back “Object Reference not set to an instance of an object” error.
Refer to the attached image and advise on a way forward.

image

Thanks, HD

@HD001

Within the Excel Application Scope please add a Read Range activity.

The Output of the Read Range activity should be assigned to the COLUMNDATA data table.

Thank you Sowmya. Now system prompt below error.

image

If: Column ‘Action’ does not belong to table DataTable.

@HD001

Haveyou added Read Range activity into the workflow or not ?

And also make sure Add Headers option field checked into it.

Yes both done.
I think the issue is with If condition now. I am using 'row.Item(“Action”).ToString.Contains(“I,R,X”)" condition. Please help!

@HD001

“I,R,X” is it in single cell ?

I have 2 conditions -

  1. If cells under column A has value ‘N’ - Abort the workflow
  2. If cells under Column A has I / R / X value continue

How do I define this?
1st image I added the flow in else with ''row.Item(“Action”).ToString.Contains(“N”)"
2nd image I have added the flow in then with “row.Item(“Action”).ToString.Contains(“I,R,X”)”

@HD001

The screenshot above nfers that Action is not a column in the data table.

Please can you post the excel sheet header info …

image

Status Action TarNo TarCd Global

Additionally column is C and not A

@HD001

Please can you check if there are leading or trailing spacing for Action …
like " Action" or "Action ". The column name should match exactly including the leading and trailing spaces.

Hi @HD001,
First of all, print your datatable using the output datatable Activity and check whether the datatable is in the expected format or not.
If it’s in expected format,
Check conditions
1)row.Item(“Action”).ToString.Contains(“N”)
2) declare a string array arr, and assign {“I”,“X”,“R”}
3) check arr.contains(row.Item(“Action”).ToString.trim)

As @SowmyaLeo said, check the header spacing