Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick create promise does not resolve #52

Open
peterbjorkmarker opened this issue Sep 14, 2023 · 6 comments
Open

Quick create promise does not resolve #52

peterbjorkmarker opened this issue Sep 14, 2023 · 6 comments

Comments

@peterbjorkmarker
Copy link

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
Copy link
Author

peterbjorkmarker commented Sep 14, 2023

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.

@DigitalFlow
Copy link
Member

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

@peterbjorkmarker
Copy link
Author

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.

@Tanuja-Gautam79
Copy link

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?

@peterbjorkmarker
Copy link
Author

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

@DigitalFlow
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants