This project is read-only.

Workflows - syntax of scripts in a decision node.

Topics: Customizing Orchard, General
Mar 6, 2014 at 9:27 PM
Edited Mar 11, 2014 at 4:52 AM
I have a Custom Contact form with a dropdown box:

Select either-
North Office, South Office.

I need to be able to fire an email to the relevant office based on the selection from the contact form.

Can I do this with Workflows...?

I created a decision node in the workflow, but I'm not sure on the rules syntax based on a token..? The token would be {Content.Fields.ContactUsForm.PreferredLocation}

But not sure of the syntax to use in the Script box? It's C# but nothing happens... If I put SetOutcome("North Office") for example it fires off the email but any conditional code results in nothing. This is Orchard v.

Using this code - including the #{ for prefixing tokens. I've tried most variations but don't seem to be having any success.
if (  #{Content.Fields.ContactUsForm.PreferredLocation} == "North Office") { 
SetOutcome("North Office");  }
else if  (  #{Content.Fields.ContactUsForm.PreferredLocation} == "South Office") {
SetOutcome("South Office");  }
Mar 11, 2014 at 3:46 AM
Bueller Bueller Bueller
Mar 13, 2014 at 10:46 PM
Is there any documentation on this.. It's not working, no matter what I try. With { brackets without { brackets, with # without #, with " without ".

Can I do it with rules instead..? I have an unhappy client and lots of pressure to get this working. It would be an easy job without Orchard.

Does this feature work - anyone else use it?
Mar 14, 2014 at 8:35 PM
Try to add #{} at the very beginning of your script
Mar 14, 2014 at 8:38 PM
actually you need to place quotes around the token: if("#{token}" == "foo")
Marked as answer by beebul on 3/16/2014 at 2:26 PM
Mar 15, 2014 at 3:17 AM
Edited Mar 16, 2014 at 10:28 PM
Putting the quote around the token, with the # did the trick!

Thanks for your help sebastien it's been driving me mad :)

Working code was:
if (  "#{Content.Fields.ContactUsForm.PreferredLocation}" == "North Office") { 
SetOutcome("North Office");  }
else if  (  "#{Content.Fields.ContactUsForm.PreferredLocation}" == "South Office") {
SetOutcome("South Office");  }
Mar 17, 2014 at 7:41 PM
Your code, if exactly like you wrote it, could be simplified ;) which gives me an idea. Why not have a branching activity like Decision which would just take a token and a list of values. The result of the token would automatically match the branch to follow. Could be in the Tokens module.
May 10, 2014 at 11:45 AM
I was looking at the decision activity yesterday... why not do this...
You don't need the Hash, and that works for me in 1.7.3
Marked as answer by beebul on 5/10/2014 at 8:50 PM