crm操作观点
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
/// <summary>
/// 视图
/// </summary>
public class UserQueryHelper
{
public static readonly string entityName = "userquery";
public Guid viewid = Guid.Empty;
public IOrganizationService service;
/// <summary>
/// 创建视图
/// </summary>
public void Create()
{
#region fetchXml
string fetchXml =@"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='opportunity'>
<order attribute='estimatedvalue' descending='false' />
<filter type='and'>
<condition attribute='statecode' operator='eq'
value='0' />
</filter>
<attribute name='name' />
<attribute name='estimatedvalue' />
<attribute name='estimatedclosedate' />
<attribute name='customerid' />
<attribute name='opportunityratingcode' />
<attribute name='closeprobability' />
<link-entity alias='opportunitycustomeridcontactcontactid'
name='contact' from='contactid' to='customerid'
link-type='outer' visible='false'>
<attribute name='emailaddress1' />
</link-entity>
<attribute name='opportunityid' />
</entity>
</fetch>";
#endregion
#region layoutXml
string layoutXml = @"<grid name='resultset' object='3' jump='name' select='1' preview='1' icon='1'>
<row name='result' id='opportunityid'>
<cell name='name' width='150' />
<cell name='customerid' width='150' />
<cell name='estimatedclosedate' width='150' />
<cell name='estimatedvalue' width='150' />
<cell name='closeprobability' width='150' />
<cell name='opportunityratingcode' width='150' />
<cell name='opportunitycustomeridcontactcontactid.emailaddress1'
width='150' disableSorting='1' />
</row>
</grid>";
#endregion
Entity en = new Entity() { LogicalName = entityName };
en["name"] = "自己定义商机视图";
en["returnedtypecode"] = "opportunity";
en["querytype"] = 0;
en["fetchxml"] = fetchXml;
en["layoutXml"] = layoutXml;
en["querytype"] = 0;
viewid = service.Create(en);
}
/// <summary>
/// 将用户查询分派给还有一用户或团队
/// </summary>
/// <param name="assignee">用户或团队引用</param>
public void Assign(EntityReference assignee)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference() { LogicalName = entityName,Id = viewid };
request.Assignee = assignee;
AssignResponse response = (AssignResponse)service.Execute(request);
}
/// <summary>
/// 运行由 ID 指定的先前保存的查询
/// </summary>
public void ExecuteByIdUserQuery()
{
ExecuteByIdUserQueryRequest request = new ExecuteByIdUserQueryRequest();
request.EntityId = new EntityReference() { LogicalName = entityName,Id = viewid };
ExecuteByIdUserQueryResponse response = (ExecuteByIdUserQueryResponse)service.Execute(request);
string result = response.String;
}
/// <summary>
/// 删除指定安全主体(用户或团队)对用户查询的全部訪问权限
/// </summary>
/// <param name="revokee">用户或团队引用</param>
public void RevokeAccess(EntityReference revokee)
{
RevokeAccessRequest request = new RevokeAccessRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = viewid };
request.Revokee = revokee;
RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
}
/// <summary>
/// 删除视图
/// </summary>
public void Delete()
{
service.Delete(entityName, viewid);
}
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
crm操作观点的更多相关文章
- crm操作业务部门
using System; using System.Linq; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messag ...
- crm操作货币实体
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; /// <summary> ...
- crm操作权限
using System; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using System.Colle ...
- crm操作知识库文章实体
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft ...
- crm操作安全角色
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using System.Co ...
- crm操作产品实体
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; /// <summary> ...
- crm操作电子邮件
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft ...
- crm操作销售订单实体
using System; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using Microsoft.Cr ...
- crm操作约会实体
using System; using Microsoft.Xrm.Sdk; using Microsoft.Crm.Sdk.Messages; using Microsoft ...
随机推荐
- java的url
中国的争论导致了扭曲
话不多说,,直接粘代码 发件人 UrlParaCode.jsp <%@ page language="java" import="java.util.*" ...
- hdu 5282 Senior's String 两次dp
题链:http://acm.hdu.edu.cn/showproblem.php?pid=5282 Senior's String Time Limit: 2000/1000 MS (Java/Oth ...
- Android-IA Power Manager (S3)
Sleep and wake up
- 怎样在屏幕上显示多个alv
本文解说怎样在屏幕上显示多个alv. 实现这种需求关键是下面几点(举例:在屏幕上显示4个alv): 1.须要定义4个alv control 2.由于有4个alv control,于是就须要定义4个容器 ...
- 算法学习 - 图的广度优先遍历(BFS) (C++)
广度优先遍历 广度优先遍历是非经常见和普遍的一种图的遍历方法了,除了BFS还有DFS也就是深度优先遍历方法.我在我下一篇博客里面会写. 遍历过程 相信每一个看这篇博客的人,都能看懂邻接链表存储图. 不 ...
- 关于Relay Log无法自己主动删除的问题(Neither --relay-log nor --relay-log-index were used)
今天查看mysql err日志.发现mysql重新启动时总会有例如以下日志出现: [Warning] Neither --relay-log nor --relay-log-index were us ...
- 学习OpenCV第0天
自2011年接触OpenCV已经有几年了,一直停留在写一些小程序,利用手冊完毕一些任务,一直没有深入研究当中代码,现在毕业,但各种原因未能进入图像处理行业,故现重学OpenCV,包含分析代码,学习算法 ...
- 怎样从Hadoop安全模式中进入正常模式
问题: 在Hadoop中,新建一个文件夹,报错了,提示mkdir: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot c ...
- Acquire and Release Semantics
An operation has acquire semantics if other processors will always see its effect before any subsequ ...
- (step7.2.2)hdu 2161(Primes——判断是否是素数)
题目大意:输入一个n,判断您是否是素数.. 解题思路:简单数论 代码如下: /* * 2161_1.cpp * * Created on: 2013年8月31日 * Author: Administr ...