At an installation where I created a helpdesk functionality based on the Help Desk template, one of the Application Templates for Windows SharePoint Services 3.0, I was asked to create a workflow which sends out an email automatically when a comments is added to a service request. The email may not be sent out if the comments added was empty.
I thought this wouldn't cause much of a problem and started creating the workflow with Microsoft Office SharePoint Designer 2007. The condition checked to evaluate if an email should be sent out was If Comments is not empty.
I created a service request, next edited it and entered a value for the Comments column. I received an email triggered by my workflow for this change, which was expected. I edited the same service request again, without entering a value for the Comments column. I received an email triggered by my workflow, which I didn't expected, as my Comments added was empty. I edited the service request again, entering a value for the Comments column, resulting in the expected reception of an email.
So apparently, the Comments column wasn't empty, even if you didn't enter a value for it upon editing the service request. I thought this had something to do with the fact that the Comments field was a Multiple lines of text type of information field with the property Append Changes to Existing Text set to Yes. But I had no idea why the workflow reacted on each change of a service request as if the Comments field wasn't empty. So I created another workflow which copied the value of the Comments field into another field. This other field had as type of information Single line of Text. I immediately understood why the workflow sent out an email each time: apparently there are <div> tags placed around each Comments field change. Not entering a value for the Comments field, nevertheless resulted in a value of <div></div>. So I changed my workflow to take this into account, and hey, no mails were sent out anymore if the end-user edited a service request without entering a value for the Comments field.
Continue reading......