cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
melamri
Resolver III
Resolver III

model-driven app Client API : disableAsyncTimeout issue

Hi, 

 

According to the following docs, when saving a form asychronously, we have 10 seconds to resolve all promises. Otherwise, an error message is displayed. This works correctly as indicated.

However, we have introduced the disableAsyncTimeout method to cancel the 10-second timeout. Unfortunately, it doesn't work as expected. The error message is still displayed after 10 seconds.

According to the roadmap, it was planned to deploy this new feature on November 22, 2021. I thought that maybe I need to be more patient to enjoy this new feature. Unfortunately, this still doesn't work. So, I opened an issue on github a few months ago. But, nobody answered, and only one person confirmed that the problem is also reproducible on his environment. 

Is this a known issue? Has anyone managed to use this new feature? Thanks

 

 

 

//Confirm Form OnSave using Async Capabilities
//disableAsyncTimeout UseCase

var MEA = window.MEA || {};
var ConfirmOnSaveForm = MEA.ConfirmOnSaveForm || {};

(function () {
    this.OnLoad = function (executionContext) {
        let eventArgs = executionContext.getEventArgs();
        if (eventArgs.getDataLoadState() == 1) {
            let formContext = executionContext.getFormContext();
            formContext.data.entity.addOnSave(this.confirmOnSave);
        }
    };
    this.confirmOnSave = function (saveCtx) {
        saveCtx.getEventArgs().disableAsyncTimeout();
        return new Promise((resolve, reject) => {
            let confirmStrings = {
                cancelButtonLabel: 'Cancel',
                confirmButtonLabel: 'Save',
                text: 'Are you sure you want to save this record ?',
                title: 'Save Confirmation'
            };
            let confirmOptions = { height: 250, width: 320 };
            Xrm.Navigation.openConfirmDialog(confirmStrings, confirmOptions).then(
                function (success) {
                    if (success.confirmed) {
                        resolve(true);
                    } else {
                        saveCtx.getEventArgs().preventDefault();
                        resolve(false);
                    }
                },
                function (error) {
                    reject(error.message);
                }
            );
        });
    };
}).call(ConfirmOnSaveForm);

 

 

 




 

5 REPLIES 5
cchannon
Super User
Super User

OK, so this isn't a direct answer to your issue (it sure sounds like you've found a feature that they failed to release as documented), but I am confused by your problem itself. If it takes more than 10 seconds to do whatever it is you're doing when this record saves, why are you making the user sit there and wait? I assume it is because the user needs some kind of output from that automation, but it still seems like it would make a pretty poor UX; no user wants to sit there twiddling their thumbs.

I'd like to make a suggestion. In-App Notifications have just hit GA with 2022 Wave 1. Instead of pushing all your events client-side and forcing a long wait on your users, why not ship your logic off to server-side in an asynchronous plugin? When the plugin is done with whatever it needs to do, it then writes an in-app notification that pops in the User's model-driven app. The user can then click on that alert to go to whatever output your automation needs them to have, but in the meantime they didn't need to sit on the form waiting for a reply; they were able to go off and do other things.

 

Of course, I don't know your use case, so that suggestion might not be at all practical, but I think something like that would be worth considering: instead of finding ways to let your code wait longer, maybe you should be finding ways to not make the user wait at all.

Thanks for your feedback, I'm not looking to implement any particular use case. I want to know why my code doesn't work, and if possible when the feature will be available. Indeed, this can waste a lot of time for a developer who relies 100% on documentation.

Hi @cchannon , 

 

The issue is about being able to show a confirm dialog in "onSave" event.
The Confirm is async, and it's great that the OnSave now waits for  promises; but that's limited to 10 seconds. The user could need longer to confirm or reject the dialog, so the OnSave won't wait for it. The disableAsnycTimeout would be great in solving this problem.

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

In that case, I'd just preventDefault to interrupt the Save entirely, THEN pop the dialog and if the user hits OK, then Save again

melamri
Resolver III
Resolver III

Yes, this is clear, and this is what was done classically before the arrival of the Asynchronous save. The shared code snippet is just an example to document this feature internally. The purpose of my question is related to the new method, why it is documented and why it was announced that it is deployed in November, while this is not functional on several environments

The goal is to understand the gap between the documentation and what is deployed, and recommend to others not to use this method at this time and also help Microsoft to improve its documentation.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Kudoed Authors
Users online (2,370)