Get the object error in if condition

Below is the error I am getting can you please guide

@Palaniyappan @lakshman

2 Likes

@balkishan

I guess null value coming from “ProfileName” variable.

3 Likes

@balkishan

To check null value try this:

String.IsNullOrEmpty(ProfileName)

3 Likes

No bro, value is there in a ProfileName var

@lakshman

2 Likes

Fine buddy
In the variable panel assign with default value to the variable in_profilename as string.Empty
And similarly for all other two variables as well like
In_phonenum and in_item
Cheers @balkishan

1 Like

@balkishan

Here, in_profilename and ProfileName both are string variables right ?

3 Likes

No, ProfileName is Generic and in_profilename is String. But I changed the ProfileName into String same error it’s throwing.

1 Like

Same error throwing bro

1 Like

@balkishan

Before IF condition put one message box and print this variable values in_profilename and ProfileName.

2 Likes

Buddy lets do one thing
use a if condition with condition like this
Not String.IsNullOrEmpty(in_profilename.ToString)
and inside the THEN part place the current if condition buddy
Cheers @balkishan

1 Like

were you able to proceed now buddy @balkishan

1 Like

Yes I am doing that bro, as you suggested

2 Likes

same error throwing bro.

@Palaniyappan please can you guide bro. Same error I am getting changed what you said.

2 Likes

@lakshman in_profilename not printing anything but ProfileName printing the name
image

2 Likes

If error is occured in in_profilename variable then definitely in_profilename is not initialized or value not exist , same for the second if condition ProfileName variable also

2 Likes

@balkishan

Have you passed input to this argument or not ?

Whenever you face this kind of errors just you debug by using write line or message box or Log message to print values and see. By using this we can easily get to know where it is failing.

2 Likes

No bro, I have assigned this to the ProfileName var. Attached the screenshot bro
image

@Palaniyappan @lakshman

1 Like

i guess in_profilename is declared in variable section and argument section.

remote it from variable section.

2 Likes

Fine lets do thing let all the value gets entered in the excel, remove all these condition, assign activity with in_profilename, in_phonenum and in_item everything…and just keep the add data row as we did earlier…that adds the value to the excel with duplicate rows where same name have two mailid
Now
–atlast before using write range workbook activity that writes the data to the excel, use a for each row loop and pass the DT variable as input to it
–inside the for each row loop use a if condition like this
row(0).ToString.Equals(DT.Rows(DT.Rows.IndexOf(row)+1)(0).ToString)
this means the first row of name is equal to its next row of name which implies that two rows have same name, and if this condition gets passed it will go to the THEN part of if condition where we can mention like this
row(1) = row(1).ToString+“,”+DT.Rows(DT.Rows.IndexOf(row)+1)(1).ToString
row(2) = row(2).ToString+“,”+DT.Rows(DT.Rows.IndexOf(row)+1)(2).ToString
and next to these two assign activity use a add to collection activity to make a note on the row index number in order to remove after this concatenation
–for that in the variable panel create a variable named rowindex_list of type list(integer) and mention the default value as new list(of integer) and now use a add to collection activity next to the above two assign activity and mention the collection as rowindex_list and in item mention as DT.Rows.IndexOf(row)+1
– so this will iterate till end we will get the value of concatenated phone number and mail id in the datatable, but still we need to remove the duplicate rows right
–so for that next to this for each row loop use a for each loop and pass the input as rowindex_list and change the type argument as int32
–inside this for each loop use a remove datarow activity, where mention the datatable as DT and row index as Item from for each loop

Hope this would work for sure
Cheers @balkishan

1 Like

Now the error is resolved, but not writing anything, as there are values in the data table.

2 Likes