D365-UI-Test icon indicating copy to clipboard operation
D365-UI-Test copied to clipboard

Quick create promise does not resolve

Open peterbjorkmarker opened this issue 2 years ago • 6 comments

Hi!

Great framework! Thanks much for open sourcing!

I am trying to use the quick create form and the form opens successfully, however the promise never resolves. I.e. test("Create insurance and calculate price", async () => { await xrmTest.Navigation.openQuickCreate("account"); const id = await xrmTest.Entity.save();
});

The save never happens and Jest times out. Any help would be greatly appreciated!.

I am testing this on an instance that has Swedish as base language (and only language installed).

peterbjorkmarker avatar Sep 14 '23 07:09 peterbjorkmarker

Did some further debugging. Removing my comment above, it is not relevant.

It seems that the promise does not resolve until after you click save and close or cancel on the quick create form. So one would need to adjust the behavior of the code to take that into account.

peterbjorkmarker avatar Sep 14 '23 14:09 peterbjorkmarker

Hi @peterbjorkmarker,

Yes, that is correct.

We call a Dynamics Utility function for opening quick create, which will also just resolve once you save or dismiss the dialog. Are you fine with adjusting your code's behavior?

Kind regards, Florian

DigitalFlow avatar Sep 19 '23 10:09 DigitalFlow

I ended up forking the code. Here is my version: ` openQuickCreate = async (options: QuickCreateOptions) => { await EnsureXrmGetter(this._page); // Cant be awaited here as the promise is not resolved until the page closes options.openFormResult = this._page.evaluate(async (entityName: string) => { const xrm = window.oss_FindXrm(); return xrm.Navigation.openForm({ entityName: entityName, useQuickCreateForm: true }); }, options.entityName); await this.page.waitForSelector("button[id^=quickCreateSaveAndCloseBtn]", { timeout: this.xrmUiTest.settings.timeout }); await this.xrmUiTest.waitForIdleness(); }

export interface QuickCreateOptions extends NavigationSettings { entityName?: string; openFormResult: Promise<Xrm.Navigation.OpenFormResult>; }

`

I await the options.openFormResult after the quick create form has been closed. As an upside I get the id back of the record I just created.

Not super clean, but works for me.

peterbjorkmarker avatar Sep 19 '23 10:09 peterbjorkmarker

I am encountering an issue with the openQuickCreate method. While it successfully opens the quick forms, the subsequent action of entering values into the form is not functioning as expected. Can anyone help me here?

Tanuja-Gautam79 avatar Mar 07 '24 22:03 Tanuja-Gautam79

See above, you need to modify the library code in question.

peterbjorkmarker avatar Mar 08 '24 08:03 peterbjorkmarker

I'll publish the fix mentioned by @peterbjorkmarker as a library functions, seems to be commonly used :)

Thanks for the discussion, I'll take care to let the release follow as soon as possible.

DigitalFlow avatar Mar 18 '24 10:03 DigitalFlow