mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-08-06 17:36:53 +01:00
Add P0 integration and control add-in guidance
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 02baffe8-0600-430d-81fa-a9993685e7cb
This commit is contained in:
parent
9214f73819
commit
cf55246ecf
16 changed files with 526 additions and 12 deletions
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
bc-version: [all]
|
||||
domain: ui
|
||||
keywords: [control-add-in, packaged-resource, ajax, withcredentials, xhrfields, jquery]
|
||||
technologies: [javascript]
|
||||
countries: [w1]
|
||||
application-area: [all]
|
||||
---
|
||||
|
||||
# Load packaged control add-in resources with credentialed AJAX
|
||||
|
||||
## Description
|
||||
|
||||
JavaScript in a Business Central control add-in can load a static resource from its extension package with AJAX, but the request needs the Business Central context and cookies. Set `xhrFields.withCredentials = true`; shorthand calls such as `$.get` omit that setting and can work during development yet fail in production.
|
||||
|
||||
## Best Practice
|
||||
|
||||
Use an AJAX form that explicitly enables `withCredentials` whenever a control add-in requests a packaged static resource. Keep this rule scoped to resources served from the add-in package; it is not generic advice to attach credentials to arbitrary external requests.
|
||||
|
||||
See sample: `control-addin-package-resource-ajax-needs-withcredentials.good.js`.
|
||||
|
||||
## Anti Pattern
|
||||
|
||||
Using `$.get(url)` or an `XMLHttpRequest` without `withCredentials = true` to retrieve package content. The request can lack the context and cookies required by the Business Central service.
|
||||
|
||||
See sample: `control-addin-package-resource-ajax-needs-withcredentials.bad.js`.
|
||||
|
||||
## Source
|
||||
|
||||
[Control add-in object: Loading static resources using AJAX requests](https://learn.microsoft.com/dynamics365/business-central/dev-itpro/developer/devenv-control-addin-object#loading-static-resources-using-ajax-requests).
|
||||
Loading…
Add table
Add a link
Reference in a new issue