1.给类型赋值不同

CRM4 plugin给lookup赋值为空 :

  1. Lookup lookupnull = new Lookup();
  2. lookupnull.IsNull = true;
  3. lookupnull.IsNullSpecified = true;
  4. entity.Properties["new_storeroom_areaid"] = lookupnull;

CRM2011 给 EntityReference 赋值为空:

  1. entity["new_storeroom_areaid"] = null;

2.单表查询,返回Entity

CRM4.0 :

  1. private DynamicEntity GetNewPrInfo(Guid NewPrID)//根据GUID查询某字段
  2. {
  3. ColumnSet colSet = new ColumnSet(NewPrInfo.EntityName);
  4. colSet.AddColumn(NewPrInfo.AttributeName_Assigner);
  5. colSet.AddColumn(NewPrInfo.AttributeName_AssignNode);
  6.  
  7. TargetRetrieveDynamic target = new TargetRetrieveDynamic();
  8. target.EntityId = NewPrID;
  9. target.EntityName = NewPrInfo.EntityName;
  10.  
  11. RetrieveRequest request = new RetrieveRequest();
  12. request.ColumnSet = colSet;
  13. request.ReturnDynamicEntities = true;
  14. request.Target = target;
  15.  
  16. RetrieveResponse response = (RetrieveResponse)this.crmService.Execute(request);
  17. DynamicEntity PromotionPe = (DynamicEntity)response.BusinessEntity;
  18. return PromotionPe;
  19. }

CRM2011:

  1. Entity accEntity = service.Retrieve(“new_test”, new_testid, new ColumnSet("字段1", "字段2"));//根据GUID,查询实体new_test的字段1和字段2的值。
  2. Entity accEntity = service.Retrieve(entityName, entityId, new ColumnSet(true));//根据GUID,查询实体new_test的所有字段。

3.初始化CRM组织服务

CRM4:

  1. CrmAuthenticationToken token = new CrmAuthenticationToken();
  2. token.AuthenticationType = ;
  3. token.OrganizationName = "AdventureWorksCycle";
  4.  
  5. CrmService service = new CrmService();
  6. service.Url = ""http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
  7. service.CrmAuthenticationTokenValue = token;
  8. service.Credentials = System.Net.CredentialCache.DefaultCredentials;

CRM2011:

  1. IFD 的服务前面的段必须是https,不分内部和外部。
  2.  
  3. Uri orgServiceUri = new Uri("https://192.168.1.101/MicrosoftDynamicCRM/XRMServices/2011/Organization.svc");
  4. ClientCredentials credentials = new ClientCredentials();
  5. credentials.UserName.UserName = CRMUserName;
  6. credentials.UserName.Password = CRMUserPassword;
  7. OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);
  8. crmService = (IOrganizationService)crmServiceProxy;
  9.  
  10. . on-premise 内部部署(AD认证),,初始化WebService时的方式如下:
  11.  
  12. 服务前面的段可以是https,也是可以http
  13.  
  14. 如果没有路由映射 外网是访问不了 只能内网访问
  15.  
  16. Uri organizationUri = new Uri("http://192.168.1.101/MicrosoftDynamicCRM/XRMServices/2011/Organization.svc");
  17. IServiceConfiguration<IOrganizationService> orgConfigInfo = ServiceConfigurationFactory.CreateConfiguration<IOrganizationService>(organizationUri);
  18. var Orgcreds = new ClientCredentials();
  19. Orgcreds.Windows.ClientCredential = new System.Net.NetworkCredential("administrator", "admiN123", "DynamicCRM.com");
  20. OrganizationServiceProxy _serviceproxy = new OrganizationServiceProxy(orgConfigInfo, Orgcreds);
  21. return (IOrganizationService)_serviceproxy;
  22.  
  23. 这样子也可以:
  24.  
  25. Uri orgServiceUri = new Uri(Config.CrmWebServiceUrl);
  26. var credentials = new ClientCredentials();
  27. credentials.Windows.ClientCredential = new System.Net.NetworkCredential(Config.CrmServerAccount, Config.CrmServerPSW, Config.CrmServerDomain);
  28. OrganizationServiceProxy _serviceproxy = new OrganizationServiceProxy(orgServiceUri, null, credentials, null);
  29. return (IOrganizationService)_serviceproxy;

4.返回多个实体

CRM4:

  1. // Create a column set holding the names of the columns to be retrieved.
  2. ColumnSet cols = new ColumnSet();
  3. cols.Attributes = new string [] {"name", "accountid"};
  4.  
  5. // Create the query object.
  6. QueryByAttribute query = new QueryByAttribute();
  7. query.ColumnSet = cols;
  8. query.EntityName = EntityName.account.ToString();
  9.  
  10. // The query will retrieve all accounts whose address1_city is Sammamish.
  11. query.Attributes = new string [] {"address1_city"};
  12. query.Values = new string [] {"Sammamish"};
  13.  
  14. // Execute the retrieval.
  15. BusinessEntityCollection retrieved = service.RetrieveMultiple(query);

CRM2011:

方法一:

  1. string fetchxml = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false' aggregate='true'>
  2. <entity name='new_po_exp_detail'>
  3. <attribute name='new_exp_amount' alias='new_exp_amount_sum' aggregate='sum' />
  4. <attribute name='new_submit_amout' alias='new_submit_amout_sum' aggregate='sum' />
  5. <attribute name='new_expense_category' alias='new_expense_category' groupby='true' />
  6. <filter type='and'>
  7. <condition attribute='statecode' operator='eq' value='0' />
  8. </filter>
  9. <link-entity name='new_po' from='new_poid' to='new_po_exp_detail' alias='ab'>
  10. <filter type='and'>
  11. <condition attribute='statecode' operator='eq' value='0' />
  12. <condition attribute='new_po_status' operator='in'>
  13. <value>5</value>
  14. <value>7</value>
  15. </condition>
  16. <condition attribute='new_promotion_pe' operator='eq' value='" + new_promotion_peId + @"' />
  17. </filter>
  18. </link-entity>
  19. </entity>
  20. </fetch>";
  21. EntityCollection entitycols = service.RetrieveMultiple(new FetchExpression(fetchxml));

方法二:

  1. QueryByAttribute query = new QueryByAttribute("new_categorytate");
  2. query.ColumnSet = new ColumnSet("new_categorytateid");
  3. query.AddAttributeValue("statecode", );
  4. query.AddAttributeValue("new_sn", new_sn);//产品品类编号
  5. EntityCollection encols = service.RetrieveMultiple(query);

Dynamics CRM4.0 和 Dynamics CRM2011 Plugin 实现一样的功能的方法的比较的更多相关文章

  1. Microsoft Dynamics CRM4.0编程---说明

    Introduction(说明) If your organization has customers, you need a software system to help you manage y ...

  2. Microsoft Dynamics CRM4.0 和 Microsoft Dynamics CRM 2011 JScript 方法对比

    CRM 2011 如果需要再IE里面调试,可以按F12在前面加上contentIFrame,比如 contentIFrame.document.getElementById("字段" ...

  3. Microsoft Dynamics CRM4.0 JScript 过滤lookup 出现 Microsoft Dynamics CRM 窗口无法打开,可能已被弹出窗口阻止程序所阻止。

    一.现象:JScript过滤lookup字段,选择lookup字段出现下图的情况: 出现:Microsoft Dynamics CRM 窗口无法打开,可能已被弹出窗口阻止程序所阻止.请将这台Micro ...

  4. Microsoft Dynamics CRM4.0 创建单据的时候,自动生成单据编号的通用方法

    一.新建两个实体,具体如下: 单据流水号(new_maxbillcode) 显示名称 名称 类型 格式 最大长度 需求级别 IME模式 备注 名称 new_name nvarchar 文本 100 业 ...

  5. Dynamics CRM 4.0升级Dynamics CRM 2013后全局Ribbon的修改

    最近在为一个客户在Dynamics CRM 4.0到Dynamics CRM 2013的升级,升级之后发现原来在Dynamics CRM 4.0中定义的全局Ribbon按钮像牛皮癣一样,在每个实体页面 ...

  6. Dynamics CRM9.0更新了Chrome后菜单按钮变形

    前段时间Chorme更新后Dynamics CRM9.0的系统菜单样式变的很难看 具体修改方法如下: 找到Dynamics CRM安装目录C:\Program Files\Microsoft Dyna ...

  7. 转载文章:Windows Azure 基础结构服务上的 Microsoft Dynamics NAV 和 Microsoft Dynamics GP!

    Windows Azure 基础结构服务(虚拟机和虚拟网络)可提供按需基础结构,该基础结构可进行伸缩以适应不断变化的业务需求.无论您是在虚拟机中创建新应用程序,还是运行现有应用程序,我们都将按分钟收费 ...

  8. Discuz 7.0版块横排显示版块图标和版块简介的方法

    Discuz 7.0版块横排显示版块图标和版块简介的方法 最近很多朋友咨询Discuz论坛设置论坛版块横排后,如何设置显示版块图标和简介的问题. 一.显示板块图标 找到templates\defaul ...

  9. 转:JMeter监控内存及CPU ——plugin插件监控被测系统资源方法

    JMeter监控内存及CPU ——plugin插件监控被测系统资源方法 jmeter中也可以监控服务器的CPU和内存使用情况,但是需要安装一些插件还需要在被监测服务器上开启服务. 1.需要的插件准备 ...

随机推荐

  1. 解决magento添加产品在前台不显示问题

    有时候我们在magento系统添加产品,前台不显示,最模板分析可能 以下几个原因: 1 添加新品要重新index一下,magento是静态的.html页面,不reindex不出来的.在System→I ...

  2. magento二次开发的基本步骤分享

    Magento后台添加新模块的体会 确定命名空间(Namespace)和模块(Modulename)的命名: 在app/etc/modules/ 路径下,创建 Namespace_Modulename ...

  3. python学习:猜数字小游戏

    在学习python过程中,没有项目做,就想到哪儿弄到哪儿. 头一发.让机器随机固定一个数字,然后让人去猜. 就这么简单.代码如下: #-*- encoding:utf8 -*- import rand ...

  4. 最小二乘法 python实现

    #-*-coding:UTF-8-*- # Created on 2015年10月20日 # @author: hanahimi import numpy as np import random im ...

  5. bootStrap-2

    全局样式: 1.移除Body的margin声明: 2.设置Body的背景色为白色: 3.为排版设置了基本的字体,字号和行高: 4.设置全局连接颜色,且当连接处于悬浮:hover状态时,才会显示下划线样 ...

  6. ASP.NET Web API与Rest web api(一)

    本文档内容大部分来源于:http://www.cnblogs.com/madyina/p/3381256.html HTTP is not just for serving up web pages. ...

  7. 自动将String类型的XML解析成实体类

    package com.mooc.freemarker2dto; public class BaseDto { } package com.mooc.freemarker2dto; public cl ...

  8. HDU 1003 Max Sum --- 经典DP

    HDU 1003    相关链接   HDU 1231题解 题目大意:给定序列个数n及n个数,求该序列的最大连续子序列的和,要求输出最大连续子序列的和以及子序列的首位位置 解题思路:经典DP,可以定义 ...

  9. php支付接口,代付、感悟

    支付接口: 1.验证用户登录信息 2.验证参数.用加密串来匹配,开信息是否被篡改 3.如果有必要可以仿造购物城 建立购物车列表 4.建立和请求方的关联表 5.进行订单生成.支付流程.各种判断.验证. ...

  10. Unable to get valid context for root

    登陆时报以下错误Unable to get valid context for rootLast login: Wed Jul 24 02:06:01 2013 from 10.64.41.3 单机模 ...