Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How to add a button to a form (not to a ribbon)

Posted on by 645

Hi, I was asked to add a button to my form near a field (not on the ribbon) can I do it in a supported way ? the button after clicked will call a function that will get data from server side (if that's matters)

thanks

  • Suggested answer
    RE: How to add a button to a form (not to a ribbon)

    Hi Partner,

    you can use the Web resource to achieve this and create a button on the Form, reference link: community.dynamics.com/.../adding-a-button-to-a-form

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to add a button to a form (not to a ribbon)

    As describe above go with HTML web resources to create the button, you can implement your service side logic in plugin. Call the plugin from CRM action , on button click you can call Action directly.

    Another way to create Rest Services and or use Web API if you are trying to fetch CRM records.

  • Suggested answer
    mobeenmohsin Profile Picture
    mobeenmohsin on at
    RE: How to add a button to a form (not to a ribbon)

    Hi Sahara,

    Hope you are doing well.

    We can add button on any form using web resource (HTML page), please follow the below steps:

    1. Navigate to Settings > Solutions > Customize the solution.

    2. Click on web resources and add new HTML web resource.

    3. Put your HTML code with button and JavaScript. Save and publish.

    4. Go to edit form and Insert web resource created above.

    We can also use https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-data-web-api to get data from server. Use below code to call web api. 

    var req = new XMLHttpRequest();

    req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/contacts(" + contactId + ")", true);

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

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

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

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

    req.onreadystatechange = function() {

       if (this.readyState === 4) {

           req.onreadystatechange = null;

           if (this.status === 204) {

               //Success - No Return Data - Do Something

           } else {

               Xrm.Utility.alertDialog(this.statusText);

           }

       }

    };

    req.send(JSON.stringify(entity));

    }

    Best Regards,

    Mobeen Mohsin

    Dynamics CRM Consultant 

  • Verified answer
    Naveen Ganeshe Profile Picture
    Naveen Ganeshe 3,393 User Group Leader on at
    RE: How to add a button to a form (not to a ribbon)

    Hi,

    You can achieve this by creating a custom button in WebResource and after that, you can add the WebResource to the form. Please follow the below blogs to achieve the same:

    https://mscrmtutorials.com/create-a-custom-html-button-in-dynamics-365/

    https://community.dynamics.com/crm/f/microsoft-dynamics-crm-forum/257055/adding-a-button-to-a-form?pifragment-97030=1#responses

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans