rd_candidate
is a lookup field. Is this correct? Is it possible to create that record using a web resource?let data = JSON.parse(urlParams);
var candidateid = data.candidateData.rd_candidateid;
skillsArray.forEach(function(skill) {
var req = new XMLHttpRequest();
req.open("POST", Xrm.Utility.getGlobalContext().getClientUrl() + "/api/data/v9.1/rd_skills", 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.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
console.log("Skill created successfully");
} else {
console.error(this.statusText);
}
}
};
"rd_candidate@odata.bind": "/rd_candidates(" + candidateid + ")",
"rd_name": skill.skill,
"rd_totalmonthsused": skill.months
};
req.send(JSON.stringify(skillData));
});