Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Create Record using Custom Button in CRM 365 and java Script

Posted on by 2,622

Hello Guys,

I am using below code to create new record in CRM using Javascript. Code is working fine if i call the method on Load of the form. But if i call the method on Custom Button. it stop working. please suggest what i am missing.


function GenerateRecord() {
debugger;
 var dummy = {};
 dummy.dam_name = "Test";
 //Create the dummy
 SDK.REST.createRecord(
     dummy,
     "dam_dummy",
     function (dummy) {
            },
     errorHandler
   );
// this.setAttribute("disabled", "disabled");
}

function errorHandler(error) {
// writeMessage(error.message);
}

*This post is locked for comments

  • Verified answer
    Inogic Profile Picture
    Inogic 24,094 on at
    RE: Create Record using Custom Button in CRM 365 and java Script

    In case you are getting the error as “SDK.REST is undefined” then you will have to include a reference to the SDK.REST in your Ribbon button before including your Javascript library. Make sure that you have added a reference to all the required Javascript libraries that are required for your code to execute.

     

    One important note here, if your CRM is CRM 2016 or above then you should use Web API to perform CRUD operation.

     

    Thanks!

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Create Record using Custom Button in CRM 365 and java Script

    Hi Vikas,

    Did you use debugger to see the reason? Is your code trigger?

    Do let me know if you have any issue.

    Thanks

    Regards,

    AW

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Create Record using Custom Button in CRM 365 and java Script

    Vikas,

    Are you getting an actual error? Do you know if the code is actually executing when you call the button click?

    I see you have a debugger statement, does the developer tools stop there?

    Let us know.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Create Record using Custom Button in CRM 365 and java Script

    Hi Vikas,

    there is no reason why the method does not work with button click; maybe you have an error in your button click code.

    Try to insert first an alert in click method, and try to debug first button click method, then when all works well reapply the create record method.

    If you need further help dont hesitate to ask (in this case, post all code you are using to achieve your goal).

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans