web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

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

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Verified answer
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    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

  • Suggested answer
    mobeenmohsin Profile Picture
    on at

    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 

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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
    AJ-22040756-0 Profile Picture
    on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans