Loading...

SAVE FORM IN DYNAMICS 365 JAVASCRIPT

SAVE FORM IN DYNAMICS 365 JAVASCRIPT

Are you curious about how to save a CRM form automatically in Dynamics 365 using JavaScript? Look no further! This tutorial will guide you through the process.

Saving records asynchronously in Dynamics 365 is straightforward with the function formContext.data.save(saveOptions).then(successCallback, errorCallback);. The function can be used to save records with callback functions to be executed after the save operation is complete.
  1. To display a successful message if the save operation is completed and a failure message if not, use the following example:

    formContext.data.save(1).then(
    function () {
    alert("Successfully Saved!");
    },
    function () {
    alert("Failed while saving!");
    });


    form save 1

    form save 2

  2. The save function takes saveOptions as a parameter to specify options for saving the record.
    The saveMode property is optional and specifies a value indicating how the save event was initiated, but setting the save mode does not actually take the corresponding action. A list of supported values is available through the getSaveMode method, which can be found through the following link.
  3. The successCallback function will be called when the operation succeeds.
  4. The errorCallback function will be called when the operation fails, and the following properties will be passed:
    - errorCode: The error code
    - message: A localized error message
Previously, the script formContext.data.entity.save(saveOption); was used to synchronously save records, with the option to close the form or open a new form after the save is complete. However, this method has now been deprecated and is no longer recommended.
  1. If no parameter is passed for the save options, the record will simply be saved. This is the same as using the Save command.
  2. saveandclose: This is the same as using the Save and Close command: formContext.data.entity.save("saveandclose");
  3. saveandnew: This is the same as using the Save and New command, with a new form opening after the save is complete: formContext.data.entity.save("saveandnew");


Happy coding!

Published on:

Learn more
Dynamics 365 Education and Knowledge
Dynamics 365 Education and Knowledge

Share post:

Related posts

Custom Subgrid Using HTML Web resource

This blog post discusses the creation of custom subgrids using HTML web resources. The ...

1 year ago

Fixed – The latitude or longitude for the User record associated with this resource is invalid – Dynamics 365 Field Service /Dataverse

If you're facing the error message "The latitude or longitude for the User record associated with this resource is invalid" while trying to se...

2 months ago

Macro Templates solution: can’t do it without a javascript web resource

Unfortunately, there is no content available for this post at the moment. Please check back later for updates. ...

3 months ago

Dynamics 365 CRM for Shipbuilding Industry: Streamlining Operations and Boosting Efficiency

This post dives into how a 150-year-old marine transportation company in the US partnered with Zelite for Dynamics 365 CRM cloud migration ser...

1 year ago

Introduction to Customizing and Extending Microsoft Dynamics CRM using Web Resource

If you're looking to extend the functionality of your Microsoft Dynamics CRM, this tutorial provides an introduction to customizing and extend...

1 year ago

How to solve 500 internal server error using Dynamics CRM web resource (HTML) as a redirect URL

If you're encountering a 500 internal server error when using Dynamics CRM web resource (HTML) as a redirect URL, you're in luck. This tutoria...

1 year ago

SETSUBMITMODE IN DYNAMICS 365 JAVASCRIPT

If you're looking to optimize your use of Dynamics 365, the setSubmitMode JavaScript method is an essential tool to keep in your arsenal. With...

1 year ago

Get Data sent to server on Save using Dynamics 365 CRM JavaScript | GetDataXML function

If you're working with forms in Dynamics 365 CRM and need to know which data has changed on save, this post is for you. There are two ways to ...

1 year ago

Webinar: Document management, data security, free up storage space, and much more within Microsoft Dynamics 365 CRM!

Managing documents and storage space within Dynamics 365 CRM can be a challenging task due to the volume of data involved, which often hampers...

2 years ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy