码迷,mamicode.com
首页 > 其他好文 > 详细

crm2011创建自定义视图

时间:2014-06-10 15:30:07      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:crm2011创建自定义视图   crm2011开发   crm2011   crm2011自定义开发   crm   

    using System;
    using Microsoft.Xrm.Sdk;

    /// <summary>
    /// 创建自定义视图
    /// </summary>
    public class CreateViewHelper
    {
        public void Create(IOrganizationService service)
        {
            //查询的FetchXml
            string fetchXml = @"<fetch version=‘1.0‘ output-format=‘xml-platform‘ mapping=‘logical‘>
                                  <entity name=‘new_class‘>
                                    <attribute name=‘new_classid‘ />
                                    <attribute name=‘new_name‘ />
                                    <attribute name=‘new_code‘ />
                                    <attribute name=‘new_num‘ />
                                    <attribute name=‘new_school‘ />
                                    <order attribute=‘new_name‘ descending=‘false‘ />
                                    <filter type=‘and‘>
                                      <condition attribute=‘new_name‘ operator=‘eq‘ value=‘实验1班‘ />
                                    </filter>
                                  </entity>
                                </fetch>";
            //呈现的布局xml
            string layoutXml = @"<grid name=‘resultset‘ object=‘10012‘ jump=‘new_name‘ select=‘1‘ icon=‘1‘ preview=‘1‘>
                                    <row name=‘result‘ id=‘new_classid‘>
                                    <cell name=‘new_name‘ width=‘150‘ />
                                    <cell name=‘new_code‘ width=‘80‘ />
                                    <cell name=‘new_num‘ width=‘100‘ />
                                    <cell name=‘new_school‘ width=‘100‘ />  
                                    </row>
                                 </grid>";

            Entity entity = new Entity() { LogicalName = "savedquery" };
            //视图的名称
            entity["name"] = "实验1班的视图";
            //视图的描述
            entity["description"] = "实验1班";
            //实体的名称
            entity["returnedtypecode"] = "new_class";
            //查询Xml
            entity["fetchxml"] = fetchXml;
            //布局Xml
            entity["layoutxml"] = layoutXml;
            //视图类型,一般默认为0
            entity["querytype"] = 0;
            //是否是默认视图
            entity["isdefault"] = false;

            service.Create(entity);
        }
    }

结果:

bubuko.com,布布扣

crm2011创建自定义视图,布布扣,bubuko.com

crm2011创建自定义视图

标签:crm2011创建自定义视图   crm2011开发   crm2011   crm2011自定义开发   crm   

原文地址:http://blog.csdn.net/y_f123/article/details/29569565

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!