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);
}
本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5224094.html,如需转载请自行联系原作者
crm使用soap创建下拉框相关推荐
- crm使用soap删除下拉框
//C# 代码: //DeleteOptionSetRequest request = new DeleteOptionSetRequest(); //request.Name = "new ...
- vue动态生成下拉框_vue+elementui 动态创建下拉框
v-for="(domain, index) in dynamicValidateForm.domains" :label="'站点' + index" :ke ...
- html input p,我想在input.phtml中创建下拉框。 (不要使用zend_form)
案例1: 在你看来: echo $this->formSelect('name', 'Option 1', array(), array('Option 1', 'Option 2')); 1 ...
- select下拉框赋值和取值
jq的select常用的方法: 一.下拉框赋值: 1.已创建select的下拉框. ①选中option的value为jquery 例:$(&qu ...
- select下拉框美化
http://dl.dbank.com/c04csxtesr 基本用法 单选下拉框的写法与传统的一样.支持TAB键打开和上下箭头选择option.支持onchange事件,见下面 选中项:2 代码如下 ...
- Excel导出模板加数据时,下拉框丢失解决方案
简介: 在工作中.我们大多数会碰到导出.导入excel功能.此篇文档便是对导出时,模板中自带的下拉框丢失的问题记录. 摘要: 首先简要描述如何实现excel导出模板加数据功能. 1.读取sheet模板 ...
- Java实现后端生成excel表格模板--下拉框实现
实现方法: //创建下拉框private static void creatDropDownList(Sheet taskInfoSheet, DataValidationHelper helper, ...
- 使用EasyExcel导出带下拉框的Excel
1. 创建注解 import java.lang.annotation.*;/*** 标注导出的列为下拉框类型,并为下拉框设置内容*/ @Documented @Retention(Retention ...
- Excel导出表格时,下拉框数据长度超过255出现的问题及解决办法
文章目录 1.直接添加下拉框,数据量过多会有问题 2.使用隐藏sheet的方式实现 3.多选下拉框 4.参考: 1.直接添加下拉框,数据量过多会有问题 /*** 创建下拉列表选项(单元格下拉框数据小于 ...
最新文章
- 自学python找工作难吗-大四应届毕业生,学了两个月Python,找工作感觉好难啊?...
- r语言的MASS包干什么的_怎么记住r语言这么多包?
- nginx配置---upstream
- KVC/KVO原理详解及编程指南
- python计算绩效工资_python实现 --工资管理系统
- grep从文件末尾开始找_新人自学前端到什么程度才能找工作?
- 模型需要对特征进行归一化吗_模型融合完全手册 - 套娃的艺术:将模型作为特征进行建模...
- [转载]jQuery操作Table学习总结
- java程序包怎么更新,从Java 8升级到Java 11-软件包sun.util不存在
- cad插件_CAD插件自动标注安装教程
- 全志和瑞芯微比较_哪家强_华为海思/全志/瑞芯微终极PK 智能芯片哪家强?
- dlib实现人脸对齐方法
- 天河二号计算机是微型计算机,计算机二级考试真题-PPT-天河二号超级计算机
- html下拉框字体大小,select下拉框选择字体大小
- camera 测光模式 和 实际应用
- 解决问题:Unable to connect to Redis
- 若为自由故——重返 Linux 世界
- 0 、 '0' 、 0 、 ’\0’ 区别
- JMC | 人工智能在药物合成中的当前和未来作用(2)
- 视频教程-深度学习与TensorFlow 2入门实战-深度学习
热门文章
- 粤桂协作消费对接活动 农业大健康·李喜贵:功能性农业合作研究
- python2.7 安装pycrypto库报错
- SmartCode 使用常见问题
- 通过html文件生成PDF文件
- 两台centos之间传送文件
- 尝试在centos5下运行phantomjs2
- POJ 2029 Get Many Persimmon Trees
- 【引用】phpmyadmin提示Access denied for user 'root'@'localhost' (using password: NO)的解决办法...
- 职业相关职位及职位能力要求知识点大纲范围
- 创建到另一个工作簿中已定义名称的外部引用的帮助(Excel)