//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. 重写PHP的explode办法

    function rexplode($delimiter, $str){ $d_len = strlen($delimiter); $arr = array(); $i = $pos = 0; whi ...

  2. ubuntu系统下给你的ipad充电(适用于所有ios设备)

    用ipad的都知道,当我们的ipad插上电脑的usb端口默认是不能充电的.windows和ubuntu平台解决办法分别如下. windows平台: 安装软件 ai_charger http://eve ...

  3. Test SRM Level One: TemperatureScales

    题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=6038 因为TopCoder SRM比赛使用的编译器进行了升级, ...

  4. 玩转web之ajax(一)---使用表单的serialize()方法中文乱码解决

    有时候我们需要使用ajax提交去提交form的值,这样就需要使用serialize()去获取form的值,但这样获取的值如果有中文,会乱码,原因和解决方法如下: 原因:.serialize()自动调用 ...

  5. Visual Prolog 的 Web 专家系统 (7)

    GENI核心 -- 推理引擎(1)知识表示 GOAL最后一句是谓语infer(),它的含义是"论证". 因此,,进GENI核心,执行视图推理引擎. infer() infer(): ...

  6. 【ThinkingInC++】53、构造函数,析构函数,全局变量

    /** * 图书:[ThinkingInC++] * 特征:构造函数,析构函数,全局变量 * 时刻:2014年9一个月17日本18:07:43 * 笔者:cutter_point */ #includ ...

  7. 键盘控制div上下左右移动 (转)

    <html> <head> <title></title> <link rel="stylesheet" type=" ...

  8. HTML——博客页面布局

    HTML文件 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/htm ...

  9. Oracle trunc()函数

    Oracle trunc()函数的用法   --Oracle trunc()函数的用法/**************日期********************/1.select trunc(sysd ...

  10. curl 命令详解(转)

    命令事例 1.读取网页,将网页内容全部输出 curl http://www.linuxidc.com 2.保存网页.下载文件 以page.html命名下载网页:curl –o page.html ht ...