CRM line Edit Control

Source: Internet
Author: User

Original, reproduced please indicate the source Wang Hongfu http://www.cnblogs.com/hellohongfu/p/4792452.html

var clienturl = "Http://172.16.30.12:5555/teachnet"//The XRM OData end-pointvar odata_endpoint = "/xrmservices/2011/organizationdata.svc";functionRetrieverecord (ID, odatasetname, successcallback, Errorcallback) {//ID is requiredif (!ID) {alert ("Record ID is required."));Return; }Else{id =encodeURIComponent (ID); }//Odatasetname is required, i.e. "Accountset"if (!Odatasetname) {alert ("Odatasetname is required."));Return; }Else{Odatasetname =encodeURIComponent (Odatasetname); }console.log (Clienturl + odata_endpoint + "/" + Odatasetname + "(GUID '" + ID + "')");//Asynchronous AJAX function to Retrieve a CRM record using OData$.ajax ({type: "GET", ContentType: "Application/json; Charset=utf-8 ", datatype: "JSON", Url:clienturl + odata_endpoint + "/" + Odatasetname + "(GUID ' + ID +" ') ", Beforesend:function(XMLHttpRequest) {//Specifying this header ensures that the results would be is returned as JSON. Xmlhttprequest.setrequestheader ("Accept", "Application/json"); }, Success:function(data, Textstatus, XMLHttpRequest) {If(Successcallback)  {Successcallback (DATA.D, Textstatus, XMLHttpRequest); }}, Error:function(XMLHttpRequest, Textstatus, Errorthrown) {If(errorcallback) Errorcallback (XMLHttpRequest, Textstatus, Errorthrown);ElseErrorHandler (XMLHttpRequest, Textstatus, Errorthrown); } });}var rowtr=$ ($ ("iframe") [0].contentwindow.document). Find ("#headerRowTR")var currentdoc=$ ($ ("iframe") [0].contentwindow.document);var button = "<input id= ' detail ' onclick= ' Detailclick () ' type= ' button ' value= ' show verbose ' > 'functionDetailclick () {alert (' test '));}//var TD =$ ($ ("iframe") [0].contentwindow.document). Find (' #chartDesignerCommandBar '). Last ();Currentdoc.find ("#contentContainer"). HTML ("<iframe src= ' http://www.baidu.com '/>"); Currentdoc.find ("#headerRowTR"). HTML ('). Append (button);functionSuccesscallback (data) {Console.log ("Successcallback:" +data);var contact=Datavar row =$ ("<div> FirstName: <input id= ' FirstName ' type= ' text value= ' ><br>lastname: <input id= ' La Stname ' type= ' text value= ' ><br>telephone1: <input id= ' Telephone1 ' type= ' text value= ' ><br> EMailAddress1: <input id= ' EMailAddress1 ' type= ' text value= ' ><br>address1_line1: <input id= ' address1_ Line1 ' type= ' text value= ' ><br>address1_city: <input id= ' address1_city ' type= ' text value= ' ><br >address1_stateorprovince: <input id= ' address1_stateorprovince ' type= ' text value= ' ><br>Address1_ PostalCode: <input id= ' address1_postalcode ' type= ' text value= ' ><br><input onclick= ' alert (' Chenggong ' value= ' Save ' type= ' button ' ></div> ');If(Contact. FirstName) Row.find ("#FirstName"). attr ("value"), contact. FirstName);If(Contact. LastName) Row.find ("#LastName"). attr ("value"), contact. LastName);If(Contact. TELEPHONE1) Row.find ("#Telephone1"). attr ("value"), contact. TELEPHONE1);If(Contact. EMAILADDRESS1) Row.find ("#EMailAddress1"). attr ("value"), contact. EMAILADDRESS1);If(Contact. ADDRESS1_LINE1) Row.find ("#Address1_Line1"). attr ("value"), contact. ADDRESS1_LINE1);If(Contact. address1_city) Row.find ("#Address1_City"). attr ("value"), contact. address1_city);If(Contact. address1_stateorprovince) Row.find ("#Address1_StateOrProvince"). attr ("value"), contact. Address1_stateorprovince);If(Contact. Address1_postalcode) Row.find ("#Address1_PostalCode"). attr ("value"), contact.   Address1_postalcode); Currentdoc.find ("#contentContainer"). append (row);}functionErrorcallback (data) {Console.log ("Errorcallback:" +data);}  function Selectedonchange (ID) {currentdoc.find ("#contentContainer"). HTML (' The current selection record is: ' +id '); Retrieverecord (ID, ' Contactset ', Successcallback,errorcallback)} var selectedid= ';   function Getselectedid () { var id =currentdoc.find (". Ms-crm-list-selectedrow"). attr (' oid ');    if (id!=selectedid) {selectedonchange (ID);  Console.log (ID); } selectedid=ID;} setinterval ("Getselectedid ()", "ten") Final effect        

CRM line Edit Control

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.