orchardcmsorchardcms-1.10

Orchard Workflow Decision Activity does not work with new line in form field


I have created workflow decision activity to determine whether submissions are spam or not. To do so, I detect if there is a link in the form field message. This has been working fine, but I discovered an issue that if a user submits the form having hit the return key (creating a new paragraph) within the message, then decision does not run and neither does the rest of the workflow.

Here is the decision script:

var message =  "#{FormSubmission.Field:message}";
if (message.ToLower().Contains("http://") ||  message.ToLower().Contains("https://")) {
SetOutcome("Spam"); 
}
else {
SetOutcome("Real"); 
}

Solution

  • Try var message = @"#{FormSubmission.Field:message}";. I'd also point out that this will have a lot of false positives, and will also miss a lot of actual spam. You should probably be using the Orchard.AntiSpam feature that comes standard with Orchard, or one of the other anti-spam modules that exist on the gallery.