Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Need to add button in ribbon

Posted on by Microsoft Employee

Hi Guys,

Thanks for your all previous informations and it will be very useful.

 I have created new entity called credit card application form and now I need to add approve button in ribbon and once I select the button the form status should changed to Approved and same for reject process.

I have added the button in ribbon but don't know how to add that functionality. Please guide me to do this.

Thanks & Regards,

Suresh K

*This post is locked for comments

  • T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: Need to add button in ribbon

    These fields could be mandatory, try populating these fields then press your button and let's see what the outcome is

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need to add button in ribbon

    Hi,

    I have followed as per the instruction and also the java script but I got an error like "You should specify a parent contact or account". our version id is 8.0.

    Could you tell me why the error is showing?

    Regards,

    Suresh K

  • Suggested answer
    Ammar Zaied Profile Picture
    Ammar Zaied 1,670 on at
    RE: Need to add button in ribbon

    Hi,

    you must use the RibbonWorkBench : ribbonworkbench.uservoice.com/.../71374-1-getting-started-with-the-ribbon-workbench

  • Suggested answer
    T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: Need to add button in ribbon

    So you have a button, for that button to be visible it needs a command.

    ribwr.PNG

    go to the command for your button (if you don't have one then create one). Then where I've put a 1, click add action and make sure you select JavaScript action. You're going to want a JavaScript function that you can reference from the ribbon workbench ( 2 = web resource where the JavaScript lives, 3 = function you want to use)

    function example() {

       debugger;

       //update

       var clientURL = Xrm.Page.context.getClientUrl();

       var recordId = Xrm.Page.data.entity.getId();

       var req = new XMLHttpRequest();

       req.open("PATCH", encodeURI(clientURL + "/api/data/v8.1/incidents(DC9E62A8-90DF-E311-9565-A45D36FC5FE8)", true)); //replace this guid with recordId

       req.setRequestHeader("Accept", "application/json");

       req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

       req.setRequestHeader("OData-MaxVersion", "4.0");

       req.setRequestHeader("OData-Version", "4.0");

       req.onreadystatechange = function () {

           if (this.readyState == 4 /* complete */) {

               req.onreadystatechange = null;

               if (this.status == 204) {          

                   alert("success");

               }

               else {

                   var error = JSON.parse(this.response).error;              

                   alert(error.message);

               }

           }

       };

       req.send(JSON.stringify(

           {

               statecode: 0,

               statuscode: 1

           }));

    }

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Need to add button in ribbon

    Hi,

    I tried that one but it's not working. Can you share me the screenshot of this process along with the java script details.

    Thanks for understanding  

  • Suggested answer
    T.I.A Profile Picture
    T.I.A 1,760 on at
    RE: Need to add button in ribbon

    Go to the commands for your button in the  ribbon workbench and add a JavaScript action. Then you need to adapt similar code to this to change the status

    syednizamsyed.blogspot.com/.../change-record-status-through-webapi-in.html

    mscrmtechie.blogspot.com/.../change-record-status-using-javascript.html

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