Adding Cancel Button On Web Page - Dynamics 365 Portal Quick Tip

Requirement

Add a custom button on Portal Page to cancel an operation.

Solution

While working on Dynamics 365 portal, sometimes, we need to add additional buttons on the web page. We can create a liquid template if we want to implement some complex logic and buttons, but if it is just a matter of a quick custom button, we can use Web Page Script area.

Let’s say we want to have a Cancel button next to the Submit button on the custom contact page. We can simply use the following steps:

  • Navigate to Web Page (Portals-> Web Pages)
  • Open the Web Page record where want to add button.
  •  Add following code in Custom Javascript field under Advanced secrion
    1. $('#InsertButton').after('<input type="button" value="Cancel" onclick="javascript:clearIsDirty();disableButtons();window.history.back();" id="CancelButton" class="btn btn-primary"/>')   

In the above code, InsertButton is the id of the button after whom we want to add our cancel button.

Note
Make sure to add this code to the content pages as well:
  • Save and Publish your changes. We should be able to see a button next to Submit button.
 
HIMBAP
We are expert in Microsoft Power Platform.