Microsoft Dynamics CRM 4.0 Plugin 取值,赋值,查询
DynamicEntity postImageEntity = (DynamicEntity)context.PostEntityImages["PostImage"];
if (postImageEntity != null)
{
Guid new_accountId = Guid.Empty;
decimal new_book_credit = 0M;
CrmDateTime new_expiry_date = new CrmDateTime(DateTime.Now.ToString());
int new_status = ;
//状态
if (postImageEntity.Properties.Contains("new_status"))
{
new_status = ((Picklist)postImageEntity.Properties["new_status"]).Value;
}
//经销商GUID
if (postImageEntity.Properties.Contains("new_account"))
{
new_accountId = ((Lookup)postImageEntity.Properties["new_account"]).Value;
}
decimal new_credit_line = 0M;
decimal new_remaining_credits = 0M;
//ColumnSet cols = new ColumnSet(new string[] { "new_credit_line", "new_remaining_credits" });
//account acc_entity = (account)crmService.Retrieve("account", new_accountId, cols);//这里和CRM2011不一样,
返回的为BusinessEntity,并且这里只能取account得系统字段的值。
//查询条件
QueryExpression query = new QueryExpression();
query.EntityName = "account";
query.ColumnSet = new ColumnSet();
query.ColumnSet.AddColumns(new string[] { "new_credit_line", "new_remaining_credits" });
//条件表达式
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "accountid";
condition.Values = new string[] { new_accountId.ToString() };
//筛选
FilterExpression filter = new FilterExpression();
filter.FilterOperator = LogicalOperator.And;
filter.Conditions.Add(condition);
query.Criteria.Filters.Add(filter);
//查询
RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;
request.ReturnDynamicEntities = true;
//响应
RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);
BusinessEntityCollection entityCollection = response.BusinessEntityCollection;
if (entityCollection.BusinessEntities.Count == ) return;
DynamicEntity acc_entity = (DynamicEntity)entityCollection.BusinessEntities[];
//期初信用额度
if (acc_entity.Properties.Contains("new_credit_line"))
{
new_credit_line = cu.RoundDecimal(((CrmMoney)acc_entity.Properties["new_credit_line"]).Value);
}
//剩余信用额度
if (acc_entity.Properties.Contains("new_remaining_credits"))
{
new_remaining_credits = cu.RoundDecimal(((CrmMoney)acc_entity.Properties["new_remaining_credits"]).Value);
}
cu.WriteLog("new_remaining_credits:" + new_remaining_credits);
//赊销额度
if (postImageEntity.Properties.Contains("new_book_credit"))
{
new_book_credit = cu.RoundDecimal(((CrmMoney)postImageEntity.Properties["new_book_credit"]).Value);
}
cu.WriteLog("new_book_credit:" + new_book_credit);
//赊销变更效期
if (postImageEntity.Properties.Contains("new_expiry_date"))
{
new_expiry_date = ((CrmDateTime)postImageEntity.Properties["new_expiry_date"]);
}
DynamicEntity accountEntity = new DynamicEntity("account");
if (!string.IsNullOrEmpty(new_book_credit.ToString()))
{
//信用额度
accountEntity.Properties.Add(new CrmMoneyProperty("new_credit_line", new CrmMoney(cu.RoundDecimal(new_book_credit))));
}
if (!string.IsNullOrEmpty(new_expiry_date.ToString()))
{
//信用额度截止日期
accountEntity.Properties.Add(new CrmDateTimeProperty("new_expiration_date", new_expiry_date));
}
decimal totalnew_credit_line = 0M;
decimal totalnew_remaining_credits = 0M;
if (string.IsNullOrEmpty(new_credit_line.ToString()))
{
new_credit_line = 0M;
}
if (string.IsNullOrEmpty(new_book_credit.ToString()))
{
new_book_credit = 0M;
}
//经销商【期初信用额度】= 起初的经销商【期初信用额度】 + 【赊销额度】
totalnew_credit_line = new_credit_line + new_book_credit;
//经销商【剩余信用额度】= 起初的经销商【剩余信用额度】 + 【赊销额度】
totalnew_remaining_credits = new_remaining_credits + new_book_credit;
//期初信用额度
accountEntity.Properties.Add(new CrmMoneyProperty("new_credit_line", new CrmMoney(totalnew_credit_line)));
//剩余信用额度
accountEntity.Properties.Add(new CrmMoneyProperty("new_remaining_credits", new CrmMoney(totalnew_remaining_credits)));
if (new_accountId != Guid.Empty)
{
accountEntity.Properties.Add(new KeyProperty("accountid", new Key(new_accountId)));
}
if (new_status == )
{
crmService.Update(accountEntity);//更新操作
}
}
Microsoft Dynamics CRM 4.0 Plugin 取值,赋值,查询的更多相关文章
- 一、Microsoft Dynamics CRM 4.0 SDK概述
Chapter 1. Microsoft Dynamics CRM 4.0 SDK Overview(SDK概述) You are probably reading this book because ...
- 从 Microsoft Dynamics CRM 4.0 server迁移到 Microsoft Dynamics CRM 2013 Server
不能就地升级早于 Microsoft Dynamics CRM Server 2011 的版本号,比方 Microsoft Dynamics CRM 4.0 server.可是,能够在升级过程中使用 ...
- Microsoft Dynamics CRM 4.0导入组织(Import Organization)时间过长的原因总结
952934 How to move the Microsoft Dynamics CRM 4.0 deployment http://support.microsoft.com/default ...
- Microsoft Dynamics CRM 9.0 OP 版本 安装 的那些 雷
天天讲安装过程好无聊了,还是搞点有营养的东西来,那么后面来说说刚出来的MSCRM OP 9.0 版本安装的那些雷: 雷1:操作系统要求Windows 2016 Server 这点还好,因为之前安装MS ...
- Microsoft Dynamics CRM 4.0 JScript 通用公共方法
1.基本参数 var CRM_FORM_TYPE_CREATE = 1; var CRM_FORM_TYPE_UPDATE = 2; var CRM_FORM_TYPE_READ_ONLY = 3; ...
- 打开安装 好的Microsoft Dynamics CRM 4.0 报错误为 Caller does not have enough privilege to set CallerOriginToken to the specified value 的解决办法
If you installed CRM 4.0 on box where you also have SQL and used a domain account as service account ...
- Microsoft Dynamics CRM 4.0 如何添加自定义按钮
一.通过导入导出ISV.Config(ISV配置),具体如下图: 先设置—>打开导出自定义项—>选择ISV配置—>选择导出所选自定义项 点击确定 保存到桌面,解压,用VS打开cust ...
- Dynamics CRM2016 升级老版本报“JavaScript Web 资源包含对 Microsoft Dynamics CRM 4.0 (2007) Web 服务终结点的引用”问题的解决办法
今天在新的服务器上部署了CRM2016 on-premises,并将CRM2015的数据库拷贝过来准备附加后升级,但在升级过程中遇到了如下错误,向导检测到了我的JavaScript Web 资源中包含 ...
- Dynamics CRM2016 升级老版本号报“JavaScript Web 资源包括对 Microsoft Dynamics CRM 4.0 (2007) Web 服务终结点的引用”问题的解决的方法
今天在新的server上部署了CRM2016 on-premises,并将CRM2015的数据库拷贝过来准备附加后升级,但在升级过程中遇到了例如以下错误.向导检測到了我的JavaScript Web ...
随机推荐
- 【转】asp.net 下的中文分词检索工具 - jieba.net
jieba是python下的一个检索库, 有人将这个库移植到了asp.net 平台下, 完全可以替代lucene.net以及盘古分词的搭配 之所以写这个, 其实是因为昨天面试时, 被问到网站的关键字检 ...
- python pipe stdout 实现cat|grep 功能
从hdfs里获取希望的数据: import subprocess for day in range(22, 23): for h in range(17, 24): filename = " ...
- hibernate一级缓存和二级缓存的区别
http://blog.csdn.net/defonds/article/details/2308972 缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了 ...
- 疑难en_a
1◆ a æ eɪ ʌ ɑː ə
- POJ 1128 拓扑排序 + 深搜
/* (⊙v⊙)嗯 貌似是一个建图 拓扑+深搜的过程.至于为什么要深搜嘛..一个月前敲得题现在全部推了重敲,于是明白了.因为题意要求如果有多个可能的解的话. * 就要输出字典序最小的那个.所以可以对2 ...
- 跟我一起学习ASP.NET 4.5 MVC4.0(三)
今天我们继续ASP.NET 4.5 MVC 4.0,前两天熟悉了MVC4.0在VS11和win8下的更新,以及MVC中的基础语法和几个关键字的使用.了解了这些就可以对MVC进一步认识,相信很多人都对M ...
- bzoj1626
题解: 简单最小生成树 x,y都要double 我也不知道为什么 代码: #include<bits/stdc++.h> using namespace std; ; int n,m,f[ ...
- Kafka生产者APi
kafka客户端发布record(消息)到kafka集群. 新的生产者是线程安全的,在线程之间共享单个生产者实例,通常单例比多个实例要快. 一个简单的例子,使用producer发送一个有序的key/v ...
- Spring学习笔记之The IoC container
IoC is also known as dependency injection (DI). 这是一个过程?什么样的过程呢?对象自己定义它的依赖关系,这意味着,那些他们依赖的对象,只能通过构造函数参 ...
- 使用 Koa + MongoDB + Redis 搭建论坛系统
koa 相对于 express 的优势在于, 1. 使用了 yield generator 封装了co 框架, 使得异步处理, 能像同步那样书写 2. 使用了 中间件 ko-schema, 使得验 ...