Condition to check if item is nothing

datatable
outlook

#1

I am trying to apply condition at 2-3 instances (in outlook and DB row). Unfortunately, following alternatives are not working for me:

  1. If row/ mail/ mail.attachment etc. isnot nothing (it returns negative result each time whether there is an attachment in mail or not or similar cases)
  2. If mail is nothing ((it returns positive result each time whether there is an attachment in mail or not or similar cases). Basically, opposite scenario of point 1
  3. Isdbnull to assess if row is blank in one of the excel rows (always return positive result)
  4. Not dbrows.Any() to assess if row is blank in one of the excel rows (always return positive result)
  5. IsNothing(item) is also not a right approach here.

I am getting my feet wet in vb.net coding so a guidance to apply condition in the following situations would be helpful:

  1. to check if no new mail/ no attachment is arrived
  2. to check if one of the excel/ db rows is empty

How to check null condition
#2

For datatable rows have you tried String.IsNullOrEmpty() - you’d have to convert your row to string first but that shouldn’t be a problem in most cases.

For the outlook problem I’m a little confused either you have a mail message or you don’t so when you are obtaining a list of mail messages you should know how many you have e.g. your mailMessages array will have 10 items. Therefore you know to check 10 messages and after that you will know that it is going to be nothing. Alternatively you would just loop through each message in mailMessages which would automatically end once you run out of messages.

Richard


Deleting cell values - Error: Input string was not in a correct format
#3
  1. I have referred String.IsNullOrEmpty() for data row items (specific column value within a row etc.) but not sure about its feasibility for each row in data table as there could be multiple blank rows within data table
  2. Actually, the code keeps running after specific time. It should identify if there is an unread/new mail and start the process.
  3. Also, I am looking for mail attachments as requested above.

#4

I was wondering if there is a solution to get extension (file format- .ppt/ .xlsx etc) of the mail attachment would also be helpful.


#5

hi @igul

Please check this post:

Regards…!!
Aksh


#6

Hi @richarddenton

I am using this technique to remove rows from a data table. I want to remove rows where a particular field is empty. The row removal technique includes a “list” variable which covers the strings to use to remove a row. How can I define a string of null values? (I tried string.IsNullOrEmpty() as the value for list but I get a compiler error)


#7

Could you post your xaml file? String.IsNullOrEmpty should work fine although it would need to go into an If statement.

An alternative approach would be to move all rows where the field is not empty into a new datatable using an Assign activity. For example newDataTable = oldDataTable.Select("yourRow<>’’ ") i…e select everything that is not blank into the new data table.

Richard


#8

Thank you Richard

I tried your second suggestion but I am getting an assign error. I have attached the xaml.

jointablepractice.zip (8.6 KB)


#9

Sorry, I’m not sure that you can directly create a datatable from another datatable. The solution I have used in the attached workflow creates a view initially and then converts it back to a datatable. The following example may help if it’s not 100%. I wasn’t sure whether your final table should be dt2 or dt3 but you can amend accordingly.

https://msdn.microsoft.com/en-us/library/73kk32zz(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

join tables more practice.xaml (14.0 KB)


#10

Thank you. Unfortunately, I am getting a target invocation exception on the view.RowFilter assignment.Any idea what will be causing that?


#11

I have it working. Thanks a million!!


#12

Hi Richard!
If i have a Data Table variable, how can check if the row is empity?
I think String.IsNullOrEmpty don’t work because i haven’t a string variable but i cannot convert it.


#13

Are you checking a particular field within that row? If so you can do the following:

string.isnullorempty(row(0).ToString)

or better…

string.isnullorempty(row(“ColumnName”).ToString)

RD


#14

Hello @richarddenton

I am a similar problem but non of suggestions above seem to work.
In my excel, several options for the row are possible, and one of them is also empty row. Which always gives us back this, whatever the condition is:

image

The only thing we expect is, that uipath won’t do anything about any empty value - so in If it’s “then” will be empty.

Can you please help?