码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-11-04 22:22:26      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   os   使用   sp   div   on   

//C#代码
//UpdateStateValueRequest updateStateValue = new UpdateStateValueRequest
//{
//    AttributeLogicalName = "statecode",
//    EntityLogicalName = "new_account_product",
//    Value = 1,
//    Label = new Label("关闭了", 2052)
//};

function demo() {
    //实体名称
    var entityname = "new_account_product";
    //属性名称
    var attrname = "statecode";
    //值
    var v = 1;
    //相应文本
    var value = "关闭了";

    updatestatevalue(entityname,attrname,v, value);
}


function updatestatevalue(entityname,attrname,v,value) {
    var resquest = "<s:Envelope xmlns:s=‘http://schemas.xmlsoap.org/soap/envelope/‘>" +
    "<s:Body>" +
    "<Execute xmlns=‘http://schemas.microsoft.com/xrm/2011/Contracts/Services‘ xmlns:i=‘http://www.w3.org/2001/XMLSchema-instance‘>" +
    "<request i:type=‘a:UpdateStateValueRequest‘ xmlns:a=‘http://schemas.microsoft.com/xrm/2011/Contracts‘>" +
    "<a:Parameters xmlns:b=‘http://schemas.datacontract.org/2004/07/System.Collections.Generic‘>" +
    "<a:KeyValuePairOfstringanyType>" +
    "<b:key>Value</b:key>" +
    "<b:value i:type=‘c:int‘ xmlns:c=‘http://www.w3.org/2001/XMLSchema‘>"+ v +"</b:value>" +
    "</a:KeyValuePairOfstringanyType>" +
    "<a:KeyValuePairOfstringanyType>" +
    "<b:key>MergeLabels</b:key>" +
    "<b:value i:type=‘c:boolean‘ xmlns:c=‘http://www.w3.org/2001/XMLSchema‘>false</b:value>" +
    "</a:KeyValuePairOfstringanyType>" +
    "<a:KeyValuePairOfstringanyType>" +
    "<b:key>AttributeLogicalName</b:key>" +
    "<b:value i:type=‘c:string‘ xmlns:c=‘http://www.w3.org/2001/XMLSchema‘>" + attrname + "</b:value>" +
    "</a:KeyValuePairOfstringanyType>" +
    "<a:KeyValuePairOfstringanyType>" +
    "<b:key>EntityLogicalName</b:key>" +
    "<b:value i:type=‘c:string‘ xmlns:c=‘http://www.w3.org/2001/XMLSchema‘>"+ entityname +"</b:value>" +
    "</a:KeyValuePairOfstringanyType>" +
    "<a:KeyValuePairOfstringanyType>" +
    "<b:key>Label</b:key>" +
    "<b:value i:type=‘a:Label‘>" +
    "<a:LocalizedLabels>" +
    "<a:LocalizedLabel>" +
    "<MetadataId i:nil=‘true‘ xmlns=‘http://schemas.microsoft.com/xrm/2011/Metadata‘ />" +
    "<HasChanged i:nil=‘true‘ xmlns=‘http://schemas.microsoft.com/xrm/2011/Metadata‘ />" +
    "<a:IsManaged i:nil=‘true‘ />" +
    "<a:Label>"+  value +"</a:Label>" +
    "<a:LanguageCode>2052</a:LanguageCode>" +
    "</a:LocalizedLabel>" +
    "</a:LocalizedLabels>" +
    "<a:UserLocalizedLabel i:nil=‘true‘ />" +
    "</b:value>" +
    "</a:KeyValuePairOfstringanyType>" +
    "</a:Parameters>" +
    "<a:RequestId i:nil=‘true‘ />" +
    "<a:RequestName>UpdateStateValue</a:RequestName>" +
    "</request>" +
    "</Execute>" +
    "</s:Body>" +
    "</s:Envelope>";

    execSoap(resquest);
}


//获取服务地址
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/Delete");
    ajaxRequest.send(request);
}

 

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

标签:style   http   io   ar   os   使用   sp   div   on   

原文地址:http://www.cnblogs.com/lcchuguo/p/4074748.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!