Skip to main content
Hi,

I improved the code to send email with data field check...

Following the value of a data field, the body is no the same...

The problem is : when I check if a field contains data using "if(K2.ProcessInstance.DataFields["RefuseReasonLegal"].Value != string.Empty)" and if the data is empty (I didn't put any data in it), the if statement is true

So my question is : What is the value of a data field which has no value? (it's a strange question but I don't know how to explain it correctly)
I would guess it would be 'null'.

Regards,
Ockert
If you want to do a string comparison on the value, cast the value to a string first, like so:
.Value.ToString() != string.Empty)


The reason is that the DataFields["FieldName"].Value is actually an object, not a string.

Bear in mind that if the string value is space(s), this statement will not evaluate correctly, you will have to trim it as well, like so:
.Value.ToString().Trim() != string.Empty)

Ok, it works now... 😃

Thank you!

Reply