Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get Data from A entity and display on B entity based on lookup field Javascript - Dynamics CRM - Dynamics 365

(0) ShareShare
ReportReport
Posted on by 1,255

Hi masters,

I have this question because i'm beign working with javascript and Dynamics CRM 2016 or the Dynamics 365 upgrade... i know it comes with some changes, but i'll go to the point...

I have data in a text field on accounts and need that data on the incidents form and on quick creation form for incidents, so i work with javascript so this is my script.

/**********************************.1.*****************************************/
function update_E_C_OnChange(){
	if(Xrm.Page.getAttribute("customerid").getValue()!=null && Xrm.Page.getAttribute("customerid").getValue()!="undefined"){
	var orgURL = "https://" + location.host +"/xrmservices/2011/OrganizationData.svc/";
	var odataSelect = "AccountSet?$select=satc_EstadoContratoHide&$filter=AccountId eq guid'" + Xrm.Page.getAttribute("customerid").getValue()[0].id + "'";
    if (typeof console != "undefined") {
      console.log(orgURL + odataSelect);
    }
    $.ajax({
      type: "GET",
      contentType: "application/json; charset=utf-8",
      datatype: "json",
      url: orgURL + odataSelect,
      beforeSend: function(XMLHttpRequest) {
        XMLHttpRequest.setRequestHeader("Accept", "application/json");
      },
      success: function(data, textStatus, XmlHttpRequest) {        
        if(data.d.results.length > 0){
          var customer = data.d.results[0];
			Xrm.Page.getAttribute("satc_estadocontrato").setValue(customer.satc_EstadoContratoHide);
			
        }
      },
      error: function(XmlHttpRequest, textStatus, errorThrown) {
        if (typeof console != "undefined") {
          console.log("ERROR: " + odataSelect + "  -  " + errorThrown);
        }
      }
    });
  }
 }

The field it's called "satc_estadocontratohide" and need to set his data on my field "satc_estadocontrato", i' getting an error tells me hey dude that function is not registered...

Update:

Basically i forgot to load jQuery before the script... Resolved :D xD

*This post is locked for comments

  • Verified answer
    Vile Andreas Rantala Profile Picture
    Vile Andreas Rantala 1,255 on at
    RE: Get Data from A entity and display on B entity based on lookup field Javascript - Dynamics CRM - Dynamics 365

    i forgot the jquery... what a badass i am XD

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans