//C# 代码:

//InsertOptionValueRequest request = new InsertOptionValueRequest();

//request.OptionSetName = "new_year";

//request.Label = new Label("2008年", languageCode);

//request.Value = 2008;

//InsertOptionValueResponse response = (InsertOptionValueResponse)service.Execute(request);

//js样例

function demo() {

    //属性名称

    var attrName = "new_year";

    //值

    var value = "2008";

    //文本

    var lable = "";

    //语言编码

    var code = 2052;

deleteAttribute(entityname, attrname);

}

function insertOption(attrName,value,lable,code) {

    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:InsertOptionValueRequest' 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>Label</b:key>";

    request += "<b:value i:type='a:Label'>";

    request += "<a:LocalizedLabels>";

    request += "<a:LocalizedLabel>";

    request += "<MetadataId i:nil='true' xmlns='http://schemas.microsoft.com/xrm/2011/Metadata' />";

    request += "<HasChanged i:nil='true' xmlns='http://schemas.microsoft.com/xrm/2011/Metadata' />";

    request += "<a:IsManaged i:nil='true' />";

    request += "<a:Label>" + lable + "</a:Label>";

    request += "<a:LanguageCode>"+ code +"</a:LanguageCode>";

    request += "</a:LocalizedLabel>";

    request += "</a:LocalizedLabels>";

    request += "<a:UserLocalizedLabel i:nil='true' />";

    request += "</b:value>";

    request += "</a:KeyValuePairOfstringanyType>";

    request += "<a:KeyValuePairOfstringanyType>";

    request += "<b:key>OptionSetName</b:key>";

    request += "<b:value i:type='c:string' xmlns:c='http://www.w3.org/2001/XMLSchema'>"+ attrName +"</b:value>";

    request += "</a:KeyValuePairOfstringanyType>";

    request += "<a:KeyValuePairOfstringanyType>";

    request += "<b:key>Value</b:key>";

    request += "<b:value i:type='c:int' xmlns:c='http://www.w3.org/2001/XMLSchema'>"+ value +"</b:value>";

    request += "</a:KeyValuePairOfstringanyType>";

    request += "</a:Parameters>";

    request += "<a:RequestId i:nil='true' />";

    request += "<a:RequestName>InsertOptionValue</a:RequestName>";

    request += "</request>";

    request += "</Execute>";

    request += "</s:Body>";

    request += "</s:Envelope>";

execSoap(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插入下拉框选项的更多相关文章

  1. crm使用soap更改下拉框的文本值

    //C#代码 //UpdateStateValueRequest updateStateValue = new UpdateStateValueRequest //{ //    AttributeL ...

  2. crm使用soap创建下拉框

    //C#代码 //#region OptionMetadataCollection //OptionMetadataCollection opCollection = new OptionMetada ...

  3. crm使用soap删除下拉框

    //C# 代码: //DeleteOptionSetRequest request = new DeleteOptionSetRequest(); //request.Name = "new ...

  4. 大型情感剧集Selenium:4_老中医教你(单/多/下拉框)选项定位 #华为云·寻找黑马程序员#

    今天讲什么 讲什么标题说了,讲selenium的单选.多选.下拉框选项定位.但其实这东西,没什么太多说的,又比较枯燥,那该怎么让这一集selenium的课程变得有趣呢?有请老中医,哈哈- 怎么样,这个 ...

  5. jq select change下拉框选项变化判断选中值,添加(attr)或移除(removeAttr)一个或多个属性

    select change下拉框选项变化判断选中值,添加(attr)或移除(removeAttr)一个或多个属性 $("#IsRecommend").change(function ...

  6. UI自动化之特殊处理二(弹框\下拉框\选项\文件上传)

    弹框\下拉框\选项\文件上传也是一些比较特殊的操作 目录 1.弹框 2.下拉框 3.选项 4.文件上传 1.弹框 弹框有三种形式,value为alert.confirm.prompt三种的弹框,第一个 ...

  7. jQuery 动态加载下拉框选项(Django)

    function change_style() { $.ajax({ url: "{% url 'change_style' %}", type: "GET", ...

  8. 巧妙解决element-ui下拉框选项过多的问题

    1. 场景描述 不知道你有没有这样的经历,下拉框的选项很多,上万个选项甚至更多,这个时候如果全部把数据放到下拉框中渲染出来,浏览器会卡死,体验会特别不好 用人会说element-ui的select有一 ...

  9. JavaScript操作select下拉框选项移动

    运行结果: 源代码: 1 <!DOCTYPE html> 2 <html lang="zh"> 3 <head> 4 <meta char ...

随机推荐

  1. 何谓集群(cluster)

    1.簇 1.1 何谓集群 简单的说.簇(cluster)是一组计算机.他们,作为一个一般的为客户提供了一套网络资源.该计算机系统是集群中的单个节点(node). 个理想的集群是,用户从来不会意识到集群 ...

  2. SIP基本呼叫

    我们首先来看下主要的呼叫流程. INVITEsip:69690067@beijing.chinamobile.com;user=phone SIP/2.0 From:"+8610696900 ...

  3. 分析java.lang.NullPointerException thrown in RelativeLayout measure()

    典型的再现环境 模型: Sony Ericsson Android version: 2.3.4 StackTrace: E/AndroidRuntime( 3579): FATAL EXCEPTIO ...

  4. 如何解决Android SDK无法下载Package的问题(.net)

    有些用户在安装好Android SDK后,打开Android SDK Manager下载API时一直显示“Done loading packages”却迟迟不能前进,界面显示的Package空空如也. ...

  5. Java Web整合开发(78) -- Struts 1

    在Struts1.3中已经取消了<data-sources>标签,也就是说只能在1.2版中配置,因为Apache不推荐在 struts-config.xml中配置数据源.所以建议不要在st ...

  6. SPOJ TWOPATHS Two Paths

    题目意思:给一棵树,找到俩个不相交的通路,使得这俩个通路的长度和乘机最大: 解法: 小哥一看呵呵 这不就是枚举点 然后求俩边的树的直径在相乘求个最大值的题么! 呵呵 这个N 有100000 当时就不玩 ...

  7. python网络爬虫学习笔记

    python网络爬虫学习笔记 By 钟桓 9月 4 2014 更新日期:9月 4 2014 文章文件夹 1. 介绍: 2. 从简单语句中開始: 3. 传送数据给server 4. HTTP头-描写叙述 ...

  8. TinyXml高速入口(一)

    笔者:朱金灿 来源:http://blog.csdn.net/clever101 对于xml文件,眼下我的工作仅仅是集中在配置文件和作为简单的信息文件来用.因此我不太喜欢使用msxml这样的重量级的x ...

  9. (转)mvn clean install 与 mvn install 的区别(为啥用clean)

    之前写代码的过程中曾经遇到过问题,用mvn install后,新改的内容不生效,一定要后来使用mvn clean install 才生效,由于之前没有做记录,以及记不清是什么情况下才会出现的问题,于是 ...

  10. 在linux上创建nfs遇到的问题。

    我们部署程序时,图片server是单独的一台server,有自己独立的域名.而应用部署在还有一台server上,我们使用一些附件上传工具.比方ajaxfileupload上传附件时是无法跨域訪问的. ...