Skip to main content

Notifications

Announcements

No record found.

Customer Service forum

Error when attempting to call WebAPI from solution configuration

Posted on by 25

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

Any idea what I could be doing wrong? How should I be doing this? The error is pretty obscure looking

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans