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
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();
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156