-
Notifications
You must be signed in to change notification settings - Fork 743
Client API updates #9709
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
Merged
quinntracy
merged 13 commits into
mendix:development
from
exec-astraea:client-api-updates
Jul 3, 2025
Merged
Client API updates #9709
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6974a0c
Updated docs that mention mx.session.getConfig("csrftoken") to use ge…
exec-astraea 002e67b
Updated docs that use mx.data.create to use the new APIs
exec-astraea 2de1bd5
Removed obsolete section on wrapping old APIs in promises
exec-astraea 5aee559
Use window.reload() instead of mx.reloadWithState()
exec-astraea edc993b
Modernized JS syntax in the examples
exec-astraea 591337e
Revise
quinntracy 457d1eb
Revise
quinntracy 47cd100
Revise
quinntracy 4165acc
Change version wording
quinntracy ccd7a3a
Minor proofreading changes
MarkvanMents c41eab4
Proofread
MarkvanMents 3a3598d
Clarify which code to use in Mx10.22 and below
MarkvanMents 000194b
Correct version number error.
MarkvanMents File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,21 +180,22 @@ For information on how to use *Big.js*, consult the [big.js API](https://mikemcl | |
|
||
#### Creating Objects | ||
|
||
Use the following code to create objects: | ||
Use the following code to create objects in Mendix version 10.23 and above: | ||
|
||
```javascript | ||
mx.data.create({ | ||
entity: "MyFirstModule.Cat", | ||
callback: function(object) { | ||
console.log("Object created on server"); | ||
}, | ||
error: function(error) { | ||
console.error("Could not commit object:", error); | ||
} | ||
}); | ||
import { create } from "mx-api/data" | ||
|
||
try { | ||
const cat = await create({ entity: "MyFirstModule.Cat" }) | ||
console.log("Object created on server:", cat); | ||
} catch (err) { | ||
console.error("Could not commit object:", err); | ||
} | ||
``` | ||
|
||
For more information on creating objects, consult the [Create](https://apidocs.rnd.mendix.com/10/client/mx.data.html#.create) section of the *Mendix Client API*. | ||
For more information on creating objects, consult the [Create](https://apidocs.rnd.mendix.com/10/client-mx-api/module-mx-api_data.html#.create) section of the *Mendix Client API*. | ||
Comment on lines
+186
to
+196
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to keep the old information as well for those who are still using MTS versions of Mendix 10. |
||
|
||
If you are using Mendix version 10.22 or below, you will need to use [`mx.data.create`](https://apidocs.rnd.mendix.com/10/client/mx.data.html#.create). | ||
|
||
#### Changing Objects | ||
|
||
|
@@ -290,11 +291,17 @@ Use the following code to employ an asynchronous return for when your nanoflow n | |
|
||
Many APIs and functions are designed in an asynchronous way, and use callback functions or promises. A JavaScript action expects a promise to be returned. The promise should be resolved with the return value as expected in the action. | ||
|
||
Explaining the callback code: | ||
|
||
* Use the standard Mendix Client to show a confirmation dialog box with an **OK** and a **Cancel** button (the execution of the nanoflow halts until the user clicks one of the buttons) | ||
* The resolve will return a Boolean value, which is used as the return value of the action | ||
* In the nanoflow, the return variable can be used for an alternative flow for confirmation and cancel | ||
|
||
#### Understanding Promises | ||
|
||
A `Promise` object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. | ||
If you are using Mendix version 10.22 or below, you will need to use promises. A `Promise` object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. | ||
|
||
Use the following code to wrap a callback API in a promise: | ||
Use the following code in Mendix versions 10.23 or below to wrap a callback API in a promise: | ||
|
||
```javascript | ||
function AskConfirmation(question) { | ||
|
@@ -314,12 +321,6 @@ function AskConfirmation(question) { | |
} | ||
``` | ||
|
||
Explaining the callback code: | ||
|
||
* Use the standard Mendix Client to show a confirmation dialog box with an **OK** and a **Cancel** button (the execution of the nanoflow halts until the user clicks one of the buttons) | ||
* The resolve will return a Boolean value, which is used as the return value of the action | ||
* In the nanoflow, the return variable can be used for an alternative flow for confirmation and cancel | ||
|
||
#### Understanding Promise API | ||
|
||
This function uses the Fetch API: | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.