创建一个dynamics CRM workflow (四) - Development of Custom Workflows
首先我们需要确定windows workflow foundation 已经安装.


创建之后先移除MyCustomWorkflows 里面的 Activity.xaml
从packages\Microsoft.CrmSdk.XrmTooling.PluginRegistrationTool.9.0.2.12\tools 路径中添加以下两个reference

复制下面的代码到我们新建的GetTaxWorkflow.cs
因为我们在CRM里面定义的custom entity是键值对的形式出现, 所以我们需要input值和output值.
我们有以下几个方式获取数据. 这里我们使用Query By Attribute
1. UsingRetrieve (必须获得GUID)
2. QueryExpression (可以实现复杂的逻辑)
3. Query By Attribute (简化的QueryExpression)
4. FatchXML
5. LINQ
public class GetTaxWorkflow : CodeActivity
{
[Input("Key")]
public InArgument<string> Key { get; set; } [Output("Tax")]
public OutArgument<string> Tax { get; set; } protected override void Execute(CodeActivityContext executionContext)
{
//Create the tracing service
ITracingService tracingService = executionContext.GetExtension<ITracingService>(); //Create the context
IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); var key = Key.Get(executionContext); // Get data from Configuraton Entity
// Call organization web service QueryByAttribute query = new QueryByAttribute("contoso_configuration");
query.ColumnSet = new ColumnSet(new string[] { "contoso_value" });
query.AddAttributeValue("contoso_name", key);
EntityCollection collection = service.RetrieveMultiple(query); if (collection.Entities.Count != )
{
tracingService.Trace("Something is wrong with configuration"); } Entity config = collection.Entities.FirstOrDefault(); tracingService.Trace(config.Attributes["contoso_value"].ToString());
Tax.Set(executionContext, config.Attributes["contoso_value"].ToString());
}
}
记得注册这个assembly

然后让我们build一下项目. 我们的workflow dll就会在debug中

创建一个dynamics CRM workflow (四) - Development of Custom Workflows的更多相关文章
- 创建一个dynamics CRM workflow (一) - Introduction to Custom Workflows
Workflow: Use this process to model and automate real world business processes. These processes can ...
- 创建一个dynamics CRM workflow (三) - Creating Configuration Entity for Custom Workflow
上个帖子中, 我们创建了个发email的workflow. 但是我们邮件当中的tax 值是 hard code, 这在开发当中是不容许的. 那今天我们来把这个build in workflow用 in ...
- 创建一个dynamics CRM workflow (二) - Build in Workflows
这里我们不着重讲解build in workflow. 但是, 如果要上手custom workflow, 我们必须要了解 build in workflow. build-in workflow 在 ...
- 创建一个dynamics CRM workflow (五) - Deploy Custom Workflows
我们打开plugin registeration tool. 注册一个新的assembly. custom workflow 和 plugin注册的方法还有些不同. 这一步custom workflo ...
- 创建一个dynamics CRM workflow (六) - Debugging Custom Workflows
我们也deploy部署了custom workflows, debugging是开发当中不可或缺的一个步骤. debug workflow的步骤和debug有些许不一样: 1. install pro ...
- 创建一个dynamics 365 CRM online plugin (四) - PreValidation
开始之前,我们要确认一下 Plugin 的 pipeline. PreValidation -> PreOperation -> Server Side System Main Event ...
- 创建一个dynamics 365 CRM online plugin (九) - Context.Depth
让我们来看看官方文档是怎么讲的 https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide ...
- 创建一个dynamics 365 CRM online plugin (七) - plugin当中的Impersonation角色
我们之前创建的plugin都是使用default的 run in User's Context. 理解就是使用正在登陆的security context用户信息 那有个问题,如果当前用户的securi ...
- 创建一个dynamics 365 CRM online plugin (十) - Isolation mode or trust mode
Isolation Mode 也被称作为Plugin Trust CRM里面有两种plugin trust / isolation mode 1. Full Trust 只在OP系统中可使用,没有限制 ...
随机推荐
- Redis学习笔记(二) - 主从复制
概述 指将一台redis服务器上的数据,复制到其他redis服务器上,前者称为主服务器(master),后者称为从服务器(slave). 默认情况下主从关系为一对多关系. 数据复制是单向的,只能从主服 ...
- Java设计模式之 — 组合(Composite)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/9153753 听说你们公司最近新推出了一款电子书阅读应用,市场反应很不错,应用里还有 ...
- Oracle关联查询-数据类型不一致问题 ORA-01722: 无效数字
一.存在表A和表B,都包含字段user_no,但数据类型不一致,如下: create table A ( user_id varchar2(20), user_no number(12,0), xxx ...
- Welcome to the Real World
 Welcome to the Real World Gregor Hohpe EnginEERS liKE pRECiSion, especially software engineers who ...
- hdu 1011 树型dp
#include <cstdio> #include <iostream> #include <cstring> #include <vector> u ...
- jQuery高性能自己定义滚动栏美化插件
malihu是一款高性能的滚动栏美化jQuery插件. 该滚动栏美化插件支持水平和垂直滚动栏,支持鼠标滚动,支持键盘滚动和支持移动触摸屏. 而且它能够和jQuery UI和Bootatrap完美的结合 ...
- 【cl】测试用例【文本框-电子邮箱】
电子邮箱控件用例: 1.只输入字母,如:abc 2.只输入数字,如:123 3.空白.空格或回车等 4.特殊的字符,如:¥,$等 5.上述四种的组合 6.不正确的邮箱组合: ①.abc@sohucom ...
- Myeclipse快捷键备忘
1.编辑类 Ctrl+定义好的类名 链接到你定义好的类的窗口 Ctrl + / 为选中的一段代码加上或去掉注释符 // (必须选中代码块) Ctrl ...
- iOS10 推送通知详解(UserNotifications)
iOS10新增加了一个UserNotificationKit(用户通知框架)来整合通知相关的API,UserNotificationKit框架增加了很多令人惊喜的特性: 更加丰富的推送内容:现在可以设 ...
- 通过top 5等待事件查看sql语句
设计的动态性能视图有:v$session_event,v$session,v$sqlarea,首先在v$session_event中可以找到event,然后通过其动态性能视图找到sid,可以在v$se ...