Adding Cancel button on Web Page – Dynamics 365 Portal Quick Tip

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

Let’s say we want to have Cancel button next to Submit button on custom contact page, we can simply use following steps:
1. Navigate to Web Page (Portals-> Web Pages)
2. Open the Web Page record where want to add button.
3. Add following code in Custom Javascript field under Advanced secrion

$('#InsertButton').after('<input type="button" value="Cancel" onclick="javascript:clearIsDirty();disableButtons();window.history.back();" id="CancelButton" class="btn btn-primary"/>')

In 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
4. Save and Publish your changes, we should be able to see button next to submit button

Leave a Reply

Your email address will not be published. Required fields are marked *