Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Xrm.WebApi.createRecord error

Posted on by 790

dear all

i am trying to run this sample code when saving a record (custom entity record), but i am getting error, can you help please.

// define the data to create new account
function create_new_account() {
    var data =
        {
            "name": "Sample Account",
            "creditonhold": false,
            "address1_latitude": 47.639583,
            "description": "This is the description of the sample account",
            "revenue": 5000000,
            "accountcategorycode": 1
        }

    // create account record
    Xrm.WebApi.createRecord("account", data).then(
        function success(result) {
            console.log("Account created with ID: " + result.id);
            // perform operations on record creation
        },
        function (error) {
            console.log(error.message);
            // handle error conditions
        }
    );
}

error :

_______________________

create_new_account@win-agqoeadqke1/.../new_create_sample_account
@win-agqoeadqke1/.../ClientApiWrapper.aspx line 157 > eval:1:1
RunHandlerInternal@win-agqoeadqke1/.../ClientApiWrapper.aspx
RunHandlers@win-agqoeadqke1/.../ClientApiWrapper.aspx
ExecuteHandler@win-agqoeadqke1/.../ClientApiWrapper.aspx
$Cb_1@win-agqoeadqke1/.../formcontrols.js
executeHandler@win-agqoeadqke1/.../formcontrols.js
executeHandlerByDescriptor@win-agqoeadqke1/.../formcontrols.js
getHandler/<@win-agqoeadqke1/.../formcontrols.js
getHandler/<@win-agqoeadqke1/.../global.ashx
$Dd_1@win-agqoeadqke1/.../formcontrols.js
$LI_1@win-agqoeadqke1/.../formcontrols.js
saveInternal@win-agqoeadqke1/.../formcontrols.js
save@win-agqoeadqke1/.../formcontrols.js
save@win-agqoeadqke1/.../formcontrols.js
Mscrm.CommandBarActions.saveForm@win-agqoeadqke1/.../commandbaractions.js
Mscrm.RibbonActions.saveForm@win-agqoeadqke1/.../ribbonactions.js
Mscrm.Utilities.executeJavascriptFunction@win-agqoeadqke1/.../global.ashx
$Cf_1@win-agqoeadqke1/.../ribbon.js
$Ag_1@win-agqoeadqke1/.../ribbon.js
handleCommand@win-agqoeadqke1/.../ribbon.js
executeCommand@win-agqoeadqke1/.../ribbon.js
executeCommand@win-agqoeadqke1/.../ribbon.js
click@win-agqoeadqke1/.../ribbon.js
onClickHandler@win-agqoeadqke1/.../ribbon.js
Function.createDelegate/<@win-agqoeadqke1/.../MicrosoftAjax.js
b@win-agqoeadqke1/.../MicrosoftAjax.js

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.WebApi.createRecord error

    I have tested in online trial v9.

    Xrm.webapi is working for v9 only.

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Xrm.WebApi.createRecord error

    Hi,

    The error showing for createRecord, what is your orgnzation version , this should work on or >9.0

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.WebApi.createRecord error

    Hi Ahmad ,

    I just test your code , and its working for me . I am suspecting something is going  wrong from your end, could you please try to register the method  another entity onsave like contact ...

  • Ahmad Saud Profile Picture
    Ahmad Saud 790 on at
    RE: Xrm.WebApi.createRecord error

    dear Goutam

    i found the error, it does not recognize the function "createRecord" , what do you think?

    thanks,

    2018_2D00_06_2D00_27-15_5F00_16_5F00_50_2D00_Account_5F00_-Company1.jpg 

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Xrm.WebApi.createRecord error

    Hi Ahmad ,

    Your code is correct , I guess the problem is coming from different source . Could you please put debugger; in your code  and its hitting the debugger or not.

    In the internet explorer just press F12 and save it will automatically go to debugger; .

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

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