You've already received a comprehensive solution for this scenario in our previous conversation. To reiterate the key points and provide a concise answer based on that discussion:
The issue you're facing is due to the asynchronous nature of the ExecutionContext.data.entity.save()
method. The Xrm.navigate.openForm()
is likely being called before the save operation has completed.
Here's the corrected approach using getIsDirty()
and Promises to ensure the save operation finishes before navigation:
Key Changes:
formContext
: Using the recommended formContext
.formContext.data.entity.getIsDirty()
: Checks for unsaved changes.save()
with .then()
: The Xrm.Navigation.openForm()
is called within the successCallback
function, ensuring it executes after the save operation completes successfully.errorCallback
for the save()
operation.Xrm.Navigation.openForm()
: Using the modern navigation API.parameters
option.Remember to replace the placeholder values ("your_new_entity_logical_name"
and "new_xyzField"
) with the actual schema names relevant to your environment. This approach guarantees that the form is saved before navigation, resolving the inconsistent behavior you were observing.
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Vahid Ghafarpour
136
Super User 2025 Season 1
Eugen Podkorytov
106