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


    //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);
    }

     

  • 相关阅读:
    mysql数据库备份脚本
    int main(int argc,char *argv[])参数的应用
    文件I/O实现cp复制功能
    网络通信TCP编程实例代码
    外部碎片、进程描述符、内部碎片
    程序、进程、作业、线程的关系
    word2016怎么从第三页开始设置页码
    ARMs3c2440开发板挂接NFS服务
    u-boot添加一个hello命令
    vi 编辑器跳转到指定行数
  • 原文地址:https://www.cnblogs.com/lcchuguo/p/4074748.html
Copyright © 2020-2023  润新知