I'm attempting to call a WebAPI method from some JavaScript on the configuration page of my solution. This is a somewhat stripped down example
window["ENTITY_SET_NAMES"] = window["ENTITY_SET_NAMES"] || JSON.stringify({
"account": "accounts",
"contact": "contacts"
});
function save() {
console.log("Saving");
try {
var Xrm = Xrm || window.parent.Xrm;
var contactId = "8553DA63-11C9-E711-A824-000D3AE0CB84";
Xrm.WebApi.retrieveRecord("contact", contactId, "$select=contactid,firstname,lastname").then((e) => { console.log(e); }).fail((e) => { console.error(e.message); });
Xrm.WebApi.createRecord('account', { 'firstname': 'Bill', 'lastname': 'testerson' }).then((e) => { console.log(e); }).fail((e) => { console.error(e.message); });
} catch (ex) {
console.error(ex);
}
return false;
}
When I attempt to run this I get an error
this.$5F_1 is null configuration.html:52:145
- j2jQuery
- save greymattercdsdev.crm.dynamics.com/.../configuration.html
- onclick greymattercdsdev.crm.dynamics.com/.../configuration.html
Any idea what I could be doing wrong? How should I be doing this? The error is pretty obscure looking