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