Condition to check if item is nothing

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
1 Like

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

  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.

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

hi @igul

Please check this post:

Regardsā€¦!!
Aksh

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)

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

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)

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)

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

1 Like

I have it working. Thanks a million!!

1 Like

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.

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

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?