创建一个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系统中可使用,没有限制 ...
随机推荐
- 洛谷P1316 丢瓶盖【二分+递推】
陶陶是个贪玩的孩子,他在地上丢了A个瓶盖,为了简化问题,我们可以当作这A个瓶盖丢在一条直线上,现在他想从这些瓶盖里找出B个,使得距离最近的2个距离最大,他想知道,最大可以到多少呢? 输入输出格式 输入 ...
- CentOS7.2 多个python版本共存
1.查看是否已经安装Python CentOS 7.2 默认安装了python2.7.5 因为一些命令要用它比如yum 它使用的是python2.7.5. 使用python -V命令查看一下是否安装P ...
- django数据库设置为MySQL
django默认使用sqlite,然后想使用MySQL数据库 在项目的setting文件中找到 DATABASES = { 'default': { 'ENGINE': 'django.db.back ...
- JVM常用参数(内存分配 内存回收日志)
内存监控 -verbose:gc 测试代码 public static void main(String[] args){ List<Classes> classes=new Array ...
- springcloud(一):Spring Cloud
研究了一段时间Spring Boot了准备向Spring Cloud进发,公司架构和项目也全面拥抱了Spring Cloud.在使用了一段时间后发现Spring Cloud从技术架构上降低了对大型系统 ...
- oracle regexp_like介绍和例子
oracle regexp_like介绍和例子 学习了:http://www.cnblogs.com/einyboy/archive/2012/08/01/2617606.html ORACLE中的支 ...
- 为Android开发人员定制的搜索引擎
我在谷歌上定制了一个专门针对Android开发人员的搜索引擎.载入慢的童鞋考虑FanQiang吧,作为技术人员使用Google才是王道. 在此推荐给大家:cx=01590883735180208228 ...
- 项目结构、包、编译为exe!
一个java源文件里至多有一个public类,该类的名称必须与源文件名称称同样.也能够没有public类.文件名称与随意一个类名一致就可以. 包 类似于cpp的namespace,是对类的再封装,防止 ...
- C#之打印乘法表
设计说明 由图可知: 1.我们需要打印出九行: 2.每行中最大列数等于行数: 代码实现 public void Display1() { Console.WriteLine("乘法表:&qu ...
- 基于ActiveMQ的消息中间件系统逻辑与物理架构设计具体解释
1. 基本介绍与组件架构图 维基百科对消息中间件的定义是"Message-oriented Middleware is software infrastructure focused on ...