首先我们需要确定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的更多相关文章

  1. 创建一个dynamics CRM workflow (一) - Introduction to Custom Workflows

    Workflow: Use this process to model and automate real world business processes. These processes can ...

  2. 创建一个dynamics CRM workflow (三) - Creating Configuration Entity for Custom Workflow

    上个帖子中, 我们创建了个发email的workflow. 但是我们邮件当中的tax 值是 hard code, 这在开发当中是不容许的. 那今天我们来把这个build in workflow用 in ...

  3. 创建一个dynamics CRM workflow (二) - Build in Workflows

    这里我们不着重讲解build in workflow. 但是, 如果要上手custom workflow, 我们必须要了解 build in workflow. build-in workflow 在 ...

  4. 创建一个dynamics CRM workflow (五) - Deploy Custom Workflows

    我们打开plugin registeration tool. 注册一个新的assembly. custom workflow 和 plugin注册的方法还有些不同. 这一步custom workflo ...

  5. 创建一个dynamics CRM workflow (六) - Debugging Custom Workflows

    我们也deploy部署了custom workflows, debugging是开发当中不可或缺的一个步骤. debug workflow的步骤和debug有些许不一样: 1. install pro ...

  6. 创建一个dynamics 365 CRM online plugin (四) - PreValidation

    开始之前,我们要确认一下 Plugin 的 pipeline. PreValidation -> PreOperation -> Server Side System Main Event ...

  7. 创建一个dynamics 365 CRM online plugin (九) - Context.Depth

    让我们来看看官方文档是怎么讲的 https://docs.microsoft.com/en-us/previous-versions/dynamicscrm-2016/developers-guide ...

  8. 创建一个dynamics 365 CRM online plugin (七) - plugin当中的Impersonation角色

    我们之前创建的plugin都是使用default的 run in User's Context. 理解就是使用正在登陆的security context用户信息 那有个问题,如果当前用户的securi ...

  9. 创建一个dynamics 365 CRM online plugin (十) - Isolation mode or trust mode

    Isolation Mode 也被称作为Plugin Trust CRM里面有两种plugin trust / isolation mode 1. Full Trust 只在OP系统中可使用,没有限制 ...

随机推荐

  1. Junit在SSH中的集成测试

    测试Spring容器 在Junit的测试类中,继承AbstractJUnit4SpringContextTests就可以进行Spring容器测试, 例如下面测试用例, @RunWith(SpringJ ...

  2. 关于Java中返回零长度数组或空集合比较好,还是返回null这个问题的一些想法

    近日在方法返回类型为List数据类型时,返回结果为空集合比较好,还是null比较好的问题上有点纠结. 我觉得应该统一返回空集合,这样可以不用进行空指针的判断,不然又多了一个产生bug的可能性.而有人认 ...

  3. 【ACM】nyoj_2_括号配对问题_201308091548

    括号配对问题时间限制:3000 ms  |  内存限制:65535 KB 难度:3描述 现在,有一行括号序列,请你检查这行括号是否配对. 输入 第一行输入一个数N(0<N<=100),表示 ...

  4. GNUPlot绘制曲线

    发现gnuplot在mac上编译安装相当方便,在线下为了測试java老堆和lucene索引大小,须要绘制两条线,可是直接点连的线很难看,所以后面使用贝塞尔曲线. 脚本例如以下: #! /usr/loc ...

  5. Aizu/Aoj 0121 Seven Puzzle

    这题应该算是经典的八数码问题的弱化版吧:给你一个4x2的方版,上面有0-7 八个数字,每次只能让编号0的方格跟他的上下左右的方格交换:所以也就是把方格0当做空格看待,每次只有空格周围的方格能够向空格处 ...

  6. SQL SERVER读书笔记:JOIN

    nested loop join:适用于小数据集,有索引的情况.不占用内存,不用tempdb. merge join:大数据,要排序,多对多,用tempdb: hash join:对大数据集,少用户使 ...

  7. Centos安装FastDFS+Nginx

    一.安装环境: gcc:安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,需要安装gcc: yum install gcc-c++ PCRE:PCRE(Perl C ...

  8. nyoj--106--背包问题(贪心,水题)

    背包问题 时间限制:3000 ms  |  内存限制:65535 KB 难度:3 描述 现在有很多物品(它们是可以分割的),我们知道它们每个物品的单位重量的价值v和重量w(1<=v,w<= ...

  9. Spring Boot:Exception parsing document: template="index", line 7 - column 3

    转自:https://blog.csdn.net/u010429286/article/details/75447561

  10. day63-webservice 08.在web项目中配置带有接口的webservice服务

    这个是配置带有接口的WebService的服务. http://localhost:8080/cxf-web-server/service 带有接口的实现类也给它做好了.jaxws:endpoint是 ...