Hi,
You can use the below code. Do remmebre to change the the chema name of you optionset field I have used "new_industry" which is there in both lead and account entity.
===============
function OnChangeParentAccount() {
var accountRef = Xrm.Page.getAttribute("parentaccountid").getValue();
if (accountRef != null && accountRef[0] != null) {
var accountId = accountRef[0].id.replace("{", "").replace("}", "");
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/accounts(" + accountId + ")?$select=new_industry", 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 accountIndustryValue = result["new_industry"];
if (accountIndustryValue != null) {
Xrm.Page.getAttribute("new_industry").setValue(accountIndustryValue);
}
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
}
}
==============
Hope this helps