CRM uses soap to change the text value in the drop-down box

Source: Internet
Author: User

// C # code
// Updatestatevaluerequest updatestatevalue = new updatestatevaluerequest
//{
// Attributelogicalname = "statecode ",
// Entitylogicalname = "new_account_product ",
// Value = 1,
// Label = new label ("disabled", 2052)
//};

Function demo (){
// Object Name
VaR entityname = "new_account_product ";
// Attribute name
VaR attrname = "statecode ";
// Value
VaR v = 1;
// Corresponding text
VaR value = "disabled ";

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: keyvaluepolicrofstringanytype>" +
"<B: Key> value </B: Key>" +
"<B: value I: TYPE = 'C: int' xmlns: c = 'HTTP: // www.w3.org/2001/xmlschema'>" + V + "</B: value>" +
"</A: keyvaluepolicrofstringanytype>" +
"<A: keyvaluepolicrofstringanytype>" +
"<B: Key> mergelabels </B: Key>" +
"<B: value I: TYPE = 'C: boolean' xmlns: c = 'HTTP: // www.w3.org/2001/xmlschema'> false </B: value>" +
"</A: keyvaluepolicrofstringanytype>" +
"<A: keyvaluepolicrofstringanytype>" +
"<B: Key> attributelogicalname </B: Key>" +
"<B: value I: TYPE = 'C: string' xmlns: c = 'HTTP: // www.w3.org/2001/xmlschema'>" + attrname + "</B: value>" +
"</A: keyvaluepolicrofstringanytype>" +
"<A: keyvaluepolicrofstringanytype>" +
"<B: Key> entitylogicalname </B: Key>" +
"<B: value I: TYPE = 'C: string' xmlns: c = 'HTTP: // www.w3.org/2001/xmlschema'>" + entityname + "</B: value>" +
"</A: keyvaluepolicrofstringanytype>" +
"<A: keyvaluepolicrofstringanytype>" +
"<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: keyvaluepolicrofstringanytype>" +
"</A: parameters>" +
"<A: requestid I: Nil = 'true'/>" +
"<A: requestname> updatestatevalue </a: requestname>" +
"</Request>" +
"</Execute>" +
"</S: Body>" +
"</S: envelope> ";

Execsoap (resquest );
}


// Obtain the service address
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 ";
}
// Run the request
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 uses soap to change the text value in the drop-down box

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.