Quantcast
Channel: Jason Lattimer's Groups Activities
Viewing all articles
Browse latest Browse all 869

SDK.REST.RETRIEVERECORD

$
0
0

Hi, I want to retrieve only the needed fields for my sdk.rest.retrieverecord
this code does his job, it copies the address of the account to the contact. But  I get all the fields of the account.. this is not performant. I want only get the fields like address1_line1, address2_line2, etc..

Any hulp is appreciated.. Below is the code

// JavaScript source code
function RetrieveAccountAddress() {
    var customerID = Xrm.Page.getAttribute("parentcustomerid").getValue()[0].id;
    var optionValue = Xrm.Page.getAttribute("slm_useaccountaddress").getValue();
    var EntitySchemaName = "Account";
 
    //var customerType = Xrm.Page.getAttribute("parentcustomerid").getValue()[0].entityType;
    //var serverurl = Xrm.Page.context.getClientUrl();
    //var OdataQuery = serverurl + "/xrmservices/2011/OrganizationData.svc/AccountSet?$filter=AccountId eq(guid'" + customerID + "')";
 
 
    if (customerID != null & optionValue == true) {
        SDK.REST.retrieveRecord(
            customerID,
      EntitySchemaName,
          null, null,
          function (account) {
              debugger;
              Xrm.Page.getAttribute("address1_line1").setValue(account.Address1_Line1);
              Xrm.Page.getAttribute("address1_line2").setValue(account.Address1_Line2);
              Xrm.Page.getAttribute("address1_line3").setValue(account.Address1_Line3);
              Xrm.Page.getAttribute("address1_city").setValue(account.Address1_City);
              Xrm.Page.getAttribute("address1_postalcode").setValue(account.Addres1_PostalCode);
              Xrm.Page.getAttribute("address1_country").setValue(account.Address1_Country);
              Xrm.Page.getAttribute("address1_stateorprovince").setValue(account.Address1_StateOrProvince);
              Xrm.Page.data.entity.save();
          },
       errorHandler
    );
 
    }
}
 
function errorHandler(error) {
    writeMessage(error.message);
}
 

Viewing all articles
Browse latest Browse all 869

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>