创建一个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系统中可使用,没有限制 ...
随机推荐
- Linux 系统查看命令
1. linux CPU大小cat /proc/cpuinfo |grep "model name" && cat /proc/cpuinfo |grep &quo ...
- js中writeln()方法
writeln( ) 方法与 write( ) 方法几乎一样,差别仅在于是前者将在所提供的任何字符串后添加一个换行符.在 HTML 中,这通常只会在后面产生一个空格:不过如果使用了 <PRE&g ...
- 关于c对文件的操作
要求从键盘输入给定文件的路径,要求将他中的内容读取出来并输入到你需要建的一个文本文档中还要从键盘输入到建的一个文本文当中 #include <stdio.h> int main() { F ...
- owin--Authentication
下面的这个从httpcontext取出来的GetOwinContext的Authentication认证有很多关于cookie和session的方法,好像不实用owin也能取出来 private IA ...
- [bzoj1708][Usaco2007 Oct]Money奶牛的硬币_动态规划_背包dp
Money奶牛的硬币 bzoj-1708 Usaco-2007 Oct 题目大意:在创立了她们自己的政权之后,奶牛们决定推广新的货币系统.在强烈的叛逆心理的驱使下,她们准备使用奇怪的面值.在传统的货币 ...
- 继续过Hard题目
接上一篇:http://www.cnblogs.com/charlesblc/p/6283064.html 继续过Hard模式的题目吧. # Title Editorial Acceptance ...
- HDU 5184
卡特兰数的一个变形而已. 一个经典的习题变过来的: n+m个人排队买票,并且满足,票价为50元,其中n个人各手持一张50元钞票,m个人各手持一张100元钞票,除此之外大家身上没有任何其他的钱币,并且初 ...
- 怎样手动的干净的删除linux上的ORACLE数据库
近期在用VMWARE虚拟机做ORACLE的数据库实验.我们都知道在WINDOWS上,我能够到加入删除程序里去自己主动删除已经安装的全部的应用程序.可是在LINUX上没有这个服务能够进行自己主动的删除. ...
- ORACLE 树形查询 树查询
前台树结构依据个人的权限登录变化 全部我查询要依据 树的ID 查询以下全部的子节点 以及本节点的信息 select * from table start with id = #{id} connect ...
- C#之打印乘法表
设计说明 由图可知: 1.我们需要打印出九行: 2.每行中最大列数等于行数: 代码实现 public void Display1() { Console.WriteLine("乘法表:&qu ...