Friday 29 May 2020

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 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 was something in HTML that is creating the issue.


<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 property # 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

No comments:

Post a Comment