Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Can't cancel from grid form after closing the form grid

Posted on by 1,530

Hi

I have a form that contains a grid.   The user clicks an item in the grid and item opens a form.  Everything is working great.

When the user enters data on a field a change event is trigger.  The event does the following displays a Dialog,  call Action Process and closes the form using Xrm.Page.ui.close().   The action process is updating a field on the entity.  The logic is working great.

The problem that I am having is when the grid form is closed and I try to close the main form.  The grid form re-display again.  I have to keep clicking cancel several times before I am able to exit from the main form.  Is there something that I need to clear?

               var displayMessage = "Are you sure you want to save the comment?\n\n **** If you select 'OK' the screen will close.";
                Xrm.Utility.confirmDialog(displayMessage,
                    function () {
                        setTimeout(function () {
                            if (templateTypeMode.text != "") {
                                var caseId = Xrm.Page.getAttribute("new_caseid").getValue()[0].id.replace(/{/g, "").replace(/}/g, "");
                                var caseDataSheetTemplateId = Xrm.Page.data.entity.getId().replace(/{/g, "").replace(/}/g, "");

                                var new_datatracking = {
                                    "new_caseid": caseId,
                                    "new_casedatasheettemplateid": caseDataSheetTemplateId.toString(),
                                    "new_templatetypemode": templateTypeMode.value.toString(),
                                    "new_reasonid": reasonId,
                                    "new_comment": comment.toString()
                                };

                                callCaseActionPlugin(new_datatracking);

                                setTimeout(function () {
                                    alert("Comment has been save!");

                                    Xrm.Page.ui.close();
                                }, 3000);
                            }
                        }, 10);
                    },


                function () {
                    setTimeout(function () {
                    }, 10);
                }
                );



*This post is locked for comments

  • Verified answer
    rthompson Profile Picture
    rthompson 1,530 on at
    RE: Can't cancel from grid form after closing the form grid

    Fixed my issue:

    Needed to change my logic to handle 2 conditions.

    switch (type) {
        case "Grid":
    If working from a grid I needs to use
              Xrm.Utility.openEntityForm(entityName, entityId);
              break;
         case "View":
    If working from a view I need to use
              Xrm.Page.data.entity.save("saveandclose");
              break;
    }


Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans