Sting.isNullorEmpty

Hallo everyone,

I need some assistance, can someone help clear the confusion here:
So I am using String.IsNullOrEmpty(EmailAPI_Body)=True, I want to say if that variable is not empty then take the value and replace:

If not It says ‘EMPTY’
Is that the best condition to use for checking an empty variable, do I have to remove the True at the end and If I do will it do what I want it to do, any advise please because on the other sequence 1 when I put =True it does not work the way it works in the first sequence 2.

Hi,

String.IsNullOrEmpty returns True if the argument is null or empty string "".
So, it seems Then and Else are swapped.

Regards,


I tested on this one it says false it’s not empty while the string is empty

Hi,

For now, can you set Breakpoint at the IF activity and run debug mode? Workflow will stop there, then check content of the variable in Locals panel?

Regards,

it shows empty


:weary:

Hi,

Can you also check its length? There seems linebreak exists.

Or try IsNullOrWhiteSpace instead of IsNullOrEmpty.

Regards,

Hi @Anelisa_Bolosha1

Try the below syntax

String.IsNullOrEmpty(EmailAPI_Body) Or String.IsNullOrWhitespace(EmailAPI_Body)

Regards

Hey @Anelisa_Bolosha1

Use below mentioned Condition in if Activity:

String.IsNullOrEmpty(EmailAPI_Body.Trim.Replace(Environment.NewLine.ToCharArray,"")) OrElse Not EmailAPI_Body.Trim.Replace(Environment.NewLine.ToCharArray,"").Length>0

Above Query will replace the New Line first then checks the length
Note: Remove double quotes in query and rewrite please!

Regards,
Ajay Mishra

Hi @Ajay_Mishra, so I want to understand do I completely remove the quotes or replace and what do I replace with there?

@Anelisa_Bolosha1 Now its correct you can use it directly, I have edited it!

If the value will be empty then bot will go to then part Or Else part.

Regards,
Ajay Mishra

1 Like


Hi @Ajay_Mishra , I have received this error

@Anelisa_Bolosha1 Ohh my mistake,

The spelling of length is wrong there!

Just correct it you will good to go!

Thankyou

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.