Skip to main content

Notifications

Announcements

No record found.

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

(1) 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

  • Suggested answer
    Kalpavruksh D365 CoE Profile Picture
    2,545 on at
    RE: Get Account id and to update the custom entity field in CRM 2013
    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/
  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at
    RE: Get Account id and to update the custom entity field in CRM 2013

    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();

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans