web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Get Account id and to update the custom entity field in CRM 2013

(0) ShareShare
ReportReport
Posted on by 44

Hi,

I am using Dynamics CRM 2013.
In Account entity, I have a custom field new_subject.
I need to get this value and update in the custom entity Subject field new_StudentSubject by using Jscript.
Whenever I will select the Account lookup on the Subject entity.

Both are text fields as a datatype.
Account to Subject we had relationship 1: N.

Thanks,

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Pawar Pravin Profile Picture
    5,237 on at

    Hi Alita,

    Please refer below code:

    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/accounts(D4C36C65-507C-E911-A994-00224800CEEF)?$select=new_subject", true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200) {
    var result = JSON.parse(this.response);
    var SubjectValue = result["new_subject"];
    Xrm.Page.getAttribute("new_StudentSubject").setValue(SubjectValue);
    } else {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send();

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    Hi,
    You will have to get guid of the selected Account and then get the field value from an Account to populate it in the custom entity.
    To fetch the values from an Account, please refer to the this link which describes oData fetch queries to get the data from parent record: http://mehmetgunen.com/retrieve-data-using-odata-queries-with-javascript-in-crm-2013/

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans