crm使用soap创建下拉框
//C#代码
//#region OptionMetadataCollection
//OptionMetadataCollection opCollection = new OptionMetadataCollection();
//opCollection.Add(new OptionMetadata(new Label("2000年", languageCode), 2000));
//opCollection.Add(new OptionMetadata(new Label("2001年", languageCode), 2001));
//opCollection.Add(new OptionMetadata(new Label("2002年", languageCode), 2002));
//opCollection.Add(new OptionMetadata(new Label("2003年", languageCode), 2003));
//opCollection.Add(new OptionMetadata(new Label("2004年", languageCode), 2004));
//opCollection.Add(new OptionMetadata(new Label("2005年", languageCode), 2005));
//#endregion
//OptionSetMetadata optionSet = new OptionSetMetadata(opCollection);
//optionSet.Name = "new_year";
//optionSet.Description = new Label("年份", languageCode);
//optionSet.DisplayName = new Label("年份", languageCode);
//optionSet.IsGlobal = true;
//optionSet.OptionSetType = OptionSetType.Picklist;
//CreateOptionSetRequest request = new CreateOptionSetRequest();
//request.OptionSet = optionSet;
//CreateOptionSetResponse response = (CreateOptionSetResponse)service.Execute(request);
//样例
function demo() {
//字段名称
var attrName = "new_year";
//标签
var labelName = "年份";
//语言编码
var code = 2052;
//集合
var dataArray = [];
dataArray.push(getOptionItem("2000年", 2000));
dataArray.push(getOptionItem("2001年", 2001));
dataArray.push(getOptionItem("2002年", 2002));
dataArray.push(getOptionItem("2003年", 2003));
dataArray.push(getOptionItem("2004年", 2004));
dataArray.push(getOptionItem("2005年", 2005));
dataArray.push(getOptionItem("2006年", 2006));
createOption(attrName, labelName, code, dataArray);
}
function getOptionItem(name, value) {
var item = new Object();
item.name = name;
item.value = value;
return item;
}
function createOption(attrName,labelName,code,dataArray) {
var request = "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'>";
request += "<s:Body>";
request += "<Execute xmlns='http://schemas.microsoft.com/xrm/2011/Contracts/Services' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>";
request += "<request i:type='a:CreateOptionSetRequest' xmlns:a='http://schemas.microsoft.com/xrm/2011/Contracts'>";
request += "<a:Parameters xmlns:b='http://schemas.datacontract.org/2004/07/System.Collections.Generic'>";
request += "<a:KeyValuePairOfstringanyType>";
request += "<b:key>OptionSet</b:key>";
request += "<b:value i:type='c:OptionSetMetadata' xmlns:c='http://schemas.microsoft.com/xrm/2011/Metadata'>";
request += "<c:MetadataId i:nil='true' />";
request += "<c:HasChanged i:nil='true' />";
request += "<c:Description>";
request += "<a:LocalizedLabels>";
request += "<a:LocalizedLabel>";
request += "<c:MetadataId i:nil='true' />";
request += "<c:HasChanged i:nil='true' />";
request += "<a:IsManaged i:nil='true' />";
request += "<a:Label>"+ labelName +"</a:Label>";
request += "<a:LanguageCode>2052</a:LanguageCode>";
request += "</a:LocalizedLabel>";
request += "</a:LocalizedLabels>";
request += "<a:UserLocalizedLabel i:nil='true' />";
request += "</c:Description>";
request += "<c:DisplayName>";
request += "<a:LocalizedLabels>";
request += "<a:LocalizedLabel>";
request += "<c:MetadataId i:nil='true' />";
request += "<c:HasChanged i:nil='true' />";
request += "<a:IsManaged i:nil='true' />";
request += "<a:Label>"+ labelName +"</a:Label>";
request += "<a:LanguageCode>2052</a:LanguageCode>";
request += "</a:LocalizedLabel>";
request += "</a:LocalizedLabels>";
request += "<a:UserLocalizedLabel i:nil='true' />";
request += " </c:DisplayName>";
request += "<c:IsCustomOptionSet i:nil='true' />";
request += "<c:IsCustomizable i:nil='true' />";
request += "<c:IsGlobal>true</c:IsGlobal>";
request += "<c:IsManaged i:nil='true' />";
request += "<c:Name>"+ attrName +"</c:Name>";
request += "<c:OptionSetType>Picklist</c:OptionSetType>";
request += "<c:Options> ";
//加入详细的每一小项
if (dataArray != null && dataArray.length > 0) {
var len = dataArray.length;
for (var i = 0; i < len; i++) {
var item = dataArray[i];
request += getItem(item.name, item.value, code);
}
}
request += "</c:Options>";
request += "</b:value>";
request += "</a:KeyValuePairOfstringanyType>";
request += "</a:Parameters>";
request += "<a:RequestId i:nil='true' />";
request += "<a:RequestName>CreateOptionSet</a:RequestName>";
request += "</request>";
request += "</Execute>";
request += "</s:Body>";
request += "</s:Envelope>";
execSoap(request);
}
function getItem(name,value,code) {
var request = "<c:OptionMetadata>";
request += "<c:MetadataId i:nil='true' />";
request += "<c:HasChanged i:nil='true' />";
request += "<c:Description i:nil='true' />";
request += "<a:IsManaged i:nil='true' />";
request += "<c:Label>";
request += "<a:LocalizedLabels>";
request += "<a:LocalizedLabel>";
request += "<c:MetadataId i:nil='true' />";
request += "<c:HasChanged i:nil='true' />";
request += "<a:IsManaged i:nil='true' />";
request += "<a:Label>" + name + "</a:Label>";
request += "<a:LanguageCode>"+ code +"</a:LanguageCode>";
request += "</a:LocalizedLabel>";
request += "</a:LocalizedLabels>";
request += "<a:UserLocalizedLabel i:nil='true' />";
request += "</c:Label>";
request += "<c:Value>"+ value +"</c:Value>";
request += "</c:OptionMetadata>";
return request;
}
//获取服务地址
function getWebUrl() {
var serverUrl = Xrm.Page.context.getServerUrl();
if (serverUrl.match(/\/$/)) {
serverUrl = serverUrl.substring(0, serverUrl.length - 1);
}
return serverUrl + "/XRMServices/2011/Organization.svc/web";
}
//运行请求
function execSoap(request) {
var ajaxRequest = new XMLHttpRequest();
ajaxRequest.open("POST", getWebUrl(), true)
ajaxRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
ajaxRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
ajaxRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
ajaxRequest.send(request);
}
crm使用soap创建下拉框的更多相关文章
- crm使用soap更改下拉框的文本值
//C#代码 //UpdateStateValueRequest updateStateValue = new UpdateStateValueRequest //{ // AttributeL ...
- crm使用soap插入下拉框选项
//C# 代码: //InsertOptionValueRequest request = new InsertOptionValueRequest(); //request.OptionSetNam ...
- crm使用soap删除下拉框
//C# 代码: //DeleteOptionSetRequest request = new DeleteOptionSetRequest(); //request.Name = "new ...
- 使用ng-options指令创建下拉框
今天在学习AngularJs中使用ng-options指令创建下拉框时遇到点问题,这里总结一下. 其实,使用ng-options指令创建下拉框很简单,只需要绑定两个属性. ng-options指令用于 ...
- layui 根据根据后台数据动态创建下拉框并同时默认选中
第一步 form表单里写好一个下拉框 <div class="layui-form-item"> <label class="layui-for ...
- jQuery无限级联下拉框插件
自己编写jQuery插件 之 无限级联下拉框 因为是级联,所以数据必须是树型结构的,我这里的测试数据如下: 看下效果图: 1.>图一: 2.>图二: 3.>图三: 由图可知,下拉 ...
- java操作poi生成excel.xlsx(设置下拉框)下载本地和前端下载
需求:导入excel表格,如果excel有错误,将错误的地方标红,在把数据以excel的形式写出,供用户下载解决方案:1.以实体类的方式接收excel并解析(创建两个集合一个接收正常的数据一个接收错误 ...
- vue自定义下拉框组件
创建下拉框组件 Select.vue <template> <div class="selects"> <div :class="{sele ...
- 雷林鹏分享:jQuery EasyUI 表单 - 创建树形下拉框
jQuery EasyUI 表单 - 创建树形下拉框 树形下拉框(ComboTree)是一个带有下列树形结构(Tree)的下拉框(ComboBox).它可以作为一个表单字段进行使用,可以提交给远程服务 ...
随机推荐
- 二分搜索(Binary Search)
当我们在字典中查找某个单的时候,一般我们会翻到一个大致的位置(假设吧,翻到中间位置),开始查找.如果翻到的正好有我们要的词,那运气好,查找结束.如果我们要找的词还在这个位置的前面,那我们对前面的这一半 ...
- 【LeetCode练习题】Reverse Words in a String
Reverse Words in a String Given an input string, reverse the string word by word. For example,Given ...
- apache http配置https
<一,Lamp系统搭建> yum install httpd httpd-devel mysql mysql-server mysql-devel php php-mysql php-co ...
- Python基础教程学习(四)类的创建与继承
类中可以有方法,类外也可以有函数,其实类就是一种封装, Python中可以自己定义一个函数,一可以把这个函数在类中封装成一个方法, 其中的属性和方法自然就从父类中继承来了, 要想获得多个类的属性和功能 ...
- YII学习(第一天)
#Apache # 设置文档根目录为 "basic/web" DocumentRoot "path/to/basic/web" <Directory &q ...
- Unity 接MM横屏闪退的原因
=.=研究了1天接SDK到处都在报错,于是使用logcat查看原因截取到这样的Exception. call to OpenGL ES API withno current context(logge ...
- 【指数型母函数+非递归快速幂】【HDU2065】"红色病毒"问题
大一上学完数分上后终于可以搞懂指数型母函数了.. 需要一点关于泰勒级数的高数知识 题目在此: "红色病毒"问题 Time Limit: 1000/1000 MS (Java/Oth ...
- kvm虚拟化之克隆篇
注意:在克隆虚拟机的时候,该虚拟机必须处于关闭状态. 1,查看目前有哪些子机并选择要克隆的子机,我选择关闭test,说明我要克隆的就是它了. 2,查看虚拟机是否关闭. virsh list --al ...
- 二、Mp3帧分析(标签帧)
Mp3文件由帧组成,帧分成标签帧和数据帧,本文就Mp3文件的帧进行分析. 一.标签帧 MP3帧头中除了存储一些象private.copyright.original的简单音乐说明信息以外,没有考虑存放 ...
- LINQ 基本子句之二 join
Join子句据说可以实现3中连接关系. 1.内部连接——元素的连接关系必须同时满足被连接的两个数据源 2.分组连接 3.左外连接 1.最基本的,内部连接,类似于sql中inner join. 由于st ...