Save and Close not working on the forms in Dynamics 365 CE

Hi Everyone,

Today I was working with HTML Webresource, we have some Hyperlinks on that. We have observed a
very strange issue, Save and Close button on the from is not working on first click after we click on the hyperlink in the HTML Webresource and it works when we click for second time.

Here is the sample source code that we had and if we remove the HTML webresource or if don’t click on the hyperlinks every thing is working fine. We were sure that there is something in HTML that is creating the issue.

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript">

        function onSomeLinkClick() {
            alert("clicked");
        }

        $(document).ready(function () {

        });

    </script>
    <title></title>
</head>
<body>
    <div>
        <a id="SomeLink" onclick="onSomeLinkClick()" href="#" title="Some Link">Some Link</a>

    </div>
    <div>I am HTML Page</div>

</body>
</html>

After checking the code slowly, we found that in href properyy # was given and that was causing this issue. As the hyperlinks has # in href, when we click the link, it is pushing the current URL to browser’s history stack and due to that we must click “Save and Close” 2 times to go back to list page. Technically Save and Close button just does “Save” and do “history back”.

Removing # from href property of Anchor tag resolved the issue.

<a id="SomeLink" onclick="onSomeLinkClick()" href="" title="Some Link">Some Link</a>

Hope this helps.


Happy 365’ing
Gopinath

2 thoughts on “Save and Close not working on the forms in Dynamics 365 CE

  1. pvraghukumar June 2, 2020 / 11:00 am

    Thanks for this post, I wasn’t aware of the SaveandClose functionality being navigated to previous page from browsing history.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s