Orchard自定义窗体和工作流 - 决策节点中脚本的语法 [英] Orchard Custom Forms and Workflows - syntax of scripts in a decision node

查看:293
本文介绍了Orchard自定义窗体和工作流 - 决策节点中脚本的语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Orchard 1.7.1.0中,我有一个包含下拉菜单的自定义联系人表单:



首选位置:
北部办公室
|南方办事处



我需要能够根据联系表格中的选择向相关办公室发送电子邮件。 Simples是??



我在工作流中创建了一个决策节点,但是我不能确定基于令牌的规则语法?令牌将像{Content.Fields.ContactUsForm.PreferredLocation}



帮助文本是您可以使用ContentItem,Services,WorkContext和T()。 SetOutcome(string result)定义活动的结果。但我似乎找不到很多其他的语法 - 我认为它只是接受C#,因为我已经看到这个提到的博客帖子,但我似乎不能得到一个简单的条件语句运行。



我遇到的问题?不会发生任何结果。如果我只是把像SetOutcome(North Office);



这与这篇文章类似,但是作者没有跟进他的工作,他被建议使用规则,所以可能不像1.7.1 Orchard那么相关。
Orchard自定义表单DropDownLists



无论如何,这是我的工作流程,代码如下。





我使用的脚本,因为我使用的令牌,我用前缀#

  if(#{Content.Fields.ContactUsForm.PreferredLocation} ==North Office){
SetOutcome(North Office); }
else if(#{Content.Fields.ContactUsForm.PreferredLocation} ==South Office){
SetOutcome(South Office); }


解决方案

找到的解决方案是在标记。

  if(#{Content.Fields.ContactUsForm.PreferredLocation}==North Office){SetOutcome北办事处); } 
else if(#{Content.Fields.ContactUsForm.PreferredLocation}==South Office){SetOutcome(South Office); }

或更简单:

  SetOutcome({Content.Fields.ContactUsForm.PreferredLocation}); 


In Orchard 1.7.1.0, I have a Custom Contact form with a drop-down:

Preferred location: 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. Simples yes??

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 something like {Content.Fields.ContactUsForm.PreferredLocation}

The help text is "You can use ContentItem, Services, WorkContext, and T(). Call SetOutcome(string outcome) to define the outcome of the activity." But I can't seem to find much else on the syntax - I assumed it just accepts C# as I've seen this mentioned on blog posts but I can't seem to get a simple conditional statement running.

The problem I'm having? ..Nothing happens.. No outcomes are fired. If I just put something like SetOutcome("North Office"); in the script field that gets actioned.

This is similar to this post, but the author didn't follow up how he got on and he was advised to use rules, so probably not as relevant to 1.7.1 Orchard. Orchard Custom Form DropDownLists

So anyway, this is my workflow and the code is below.

Thanks for any suggestions..

The script I'm using, because I'm using tokens I've prefixed them with #

if (  #{Content.Fields.ContactUsForm.PreferredLocation} == "North Office") { 
SetOutcome("North Office");  }
else if  (  #{Content.Fields.ContactUsForm.PreferredLocation} == "South Office") {
SetOutcome("South Office");  }

解决方案

Found the solution was to add quotes around the tokens.

    if (  "#{Content.Fields.ContactUsForm.PreferredLocation}" == "North Office") { SetOutcome("North Office");  }
else if  (  "#{Content.Fields.ContactUsForm.PreferredLocation}" == "South Office") { SetOutcome("South Office");  }

Or even simpler:

SetOutcome("{Content.Fields.ContactUsForm.PreferredLocation}");

这篇关于Orchard自定义窗体和工作流 - 决策节点中脚本的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆