What is possible in Decision Activity

Topics: Customizing Orchard
Nov 3, 2014 at 10:55 PM
Edited Nov 3, 2014 at 10:57 PM
I am running out of ideas. I have a ContentPart called "PlattformUserPart" and a ContentType "PlattformUser" where this Part and the UserPart are attached.

Now I created a "UserLogin" - Event and pass the contentitem to the workflow. Now I tried the following code to access a property of the "PlattformUserPart" in a Decision Activity:
(ContentItem.PlattformUserPart.ProfileFinished == true) ? SetOutcome("Yes") :SetOutcome("No")
(ContentItem.As<PlattformUserPart>().ProfileFinished == true) ? SetOutcome("Yes") :SetOutcome("No")
I created a Tokenprovider and tried this:
({Content.PlattformUserPart.ProfileFinished} == true) ? SetOutcome("Yes") :SetOutcome("No")
I also got no error messages in my log file.

What is possible to access this property? What are the restrictions in the Scripting Module? Is there a way to add a button to check if the code compiles?

Nov 4, 2014 at 1:44 AM
Ok, I found a solution myself. But it's a little bit weird.

Solution: (hopefully found this https://orchard.codeplex.com/discussions/465408)
// #{}
if(ContentItem.PlattformUserPart.ProfileFinished == true)
Now my question: Why is in the Decision Activity AFTER the tokens getting parsed this line:
script = "// #{ }" + System.Environment.NewLine + script;
Shouldn't that before the tokens getting parsed?
Nov 4, 2014 at 6:55 AM
By placing the tokenizer block #{} before the script your tricking the tokenizer to evaluate only whats in the block , which is empty.
This way the script the follows will be ignored by tokenizer , and will be evaluated correctly by c# compiler.
If the tokenizer block was not at the beginning before the actual script then the whole script will be evaluated by the tokenizer ,
so something like :
will be considered as a token and wont produce anything.

So basically we are separating what is to be tokenized and what needs to be evaluated by c# compiler.
Nov 4, 2014 at 2:46 PM
Ok, thanks. But as explained in this post the tokenizer searches first for #{..} tokens and if there is one found it presumes that the 'new' token format is used. So if I need more tokens in my script I have to write #{Content.Id} in my script - is that right so far?
The confusing thing nevertheless is, that the field in the Decision Activity has a token drop-down and this tokens are with {}. In this case it seems a little bit inconsistent.

But the other question for me is, why is this line in the decision activity (after the tokens getting parsed)?
script = "// #{ }" + System.Environment.NewLine + script;