柚子快报怎么发布任务778899分享:crm使用soap创建下拉框

http://yzkb.51969.com/

//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 = "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "OptionSet";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += ""+ labelName +"";

    request += "2052";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += ""+ labelName +"";

    request += "2052";

    request += "";

    request += "";

    request += "";

    request += " ";

    request += "";

    request += "";

    request += "true";

    request += "";

    request += ""+ attrName +"";

    request += "Picklist";

    request += " ";

    //加入详细的每一小项

    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 += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "CreateOptionSet";

    request += "";

    request += "";

    request += "";

    request += "";

    execSoap(request);

}

function getItem(name,value,code) {

    var request = "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "";

    request += "" + name + "";

    request += ""+ code +"";

    request += "";

    request += "";

    request += "";

    request += "";

    request += ""+ value +"";

    request += "";

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

}

柚子快报怎么发布任务778899分享:crm使用soap创建下拉框

http://yzkb.51969.com/

文章来源

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。
大家都在看: