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).它可以作为一个表单字段进行使用,可以提交给远程服务 ...
随机推荐
- 【转】android 电容屏(二):驱动调试之基本概念篇
关键词:android 电容屏 tp 工作队列 中断 多点触摸协议平台信息:内核:linux2.6/linux3.0系统:android/android4.0 平台:S5PV310(samsung ...
- Yougth的最大化(好题,二分查找 0 1分数规划)
Yougth的最大化 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 Yougth现在有n个物品的重量和价值分别是Wi和Vi,你能帮他从中选出k个物品使得单位重量的价 ...
- SPOJ GCDEX (数论)
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents by---cxlove 题意:求sigma (gcd (i , j)) ...
- jQuery支持移动Mobile的DOM元素移动和缩放插件
jQuery Panzoom是一款很有用的HTML DOM元素平移和缩放jQuery和CSS3插件. Panzoom利用CSS transforms 和 matrix函数来为浏览器进行硬件(GPU)加 ...
- webapp 性能优化
webapp 不像传统页面,它生命周期更长,在手机端上,硬件环境并没有pc上那么好.所以性能的优化尤为重要. webapp的性能优化主要分为两个方面 网络请求优化 和 页面渲染优化 , 我们对于性能优 ...
- C# 坦克大战学习总结
1.学会用Resource管理资源 添加资源 在properties下的Resource.resx添加资源 使用资源 工程名.Properties.Resource.资源名 实际本质,是一个流. 2. ...
- 【错排问题】【HDU2048】神、上帝以及老天爷
神.上帝以及老天爷 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total ...
- 【.NetRemoting-3】2015.09.18
[Remoting程序的基本实现] [一]服务程序集 [1]服务对象必须要求继承[MBR,MarshalByRefObject] [二]服务端应用程序 [1]注册通道 [两种类型的通道] [A]发送请 ...
- H - Ones
Description Given any integer 0 <= n <= 10000 not divisible by 2 or 5, some multiple of n is a ...
- Sublime Text 3 个人配置文件
{ "dpi_scale": 1.0, "draw_white_space": "selection", "fallback_en ...