All Content
explore our new search
Triggering formOnLoad Event After Saving in MDA
Image Source:
Developer Tools
Sep 30, 2023 7:17 AM

Triggering formOnLoad Event After Saving in MDA

by HubSite 365 about Temmy Wahyu Raharjo

Citizen DeveloperDeveloper ToolsDynamics 365M365 Hot News

Uncover how to manage UI appearance based on conditions using form onLoad event in Microsoft Dynamics via JavaScript scripting.

Summarizing The User Interface Management Using JavaScript in the Form onLoad Event

The focus of this blog post by Temmy Wahyu Raharjo lies on managing the user interface (UI) based on certain conditions using the form onLoad event in JavaScript. This is commonly done when the status of a table or entity is Inactive, requiring all controls to be locked.

Here is a JavaScript template he provided to manage the UI.

``` var demo = demo || {}; (function () { this.onLoad = function (executionContext) { var formContext = executionContext.getFormContext(); formContext.getControl('tmy_contact').addPreSearch(this.filterContact); formContext.getAttribute('tmy_name').addOnChange(this.onNameChange); }; }).apply(demo); ```

To call demo.onLoad after saving, the author suggests adding the “Modified On” attribute to the form - an attribute that can be set as hidden if needed. After saving, an automatic update from the backend to the UI occurs, which triggers the event we've just added.

Something the author cautions about is if we're using addOnChange, addPreSearch, or other methods that add a function from the script, we need to be particularly cautious. We might face an issue of the event being called more than once, depending on how many times the formOnLoad is called. Therefore, adjustments need to be made to the JavaScript to avoid this. Here you can find more information about it Developer Tools

The solution proposed by the author revolves around the use of addOnPostSave method if you don’t wish to add the “Modified On” field to the form. But remember, you then need to disable the “Modified On” change event.

In summary, ensuring the onLoad event can be easily called after data is saved is crucial. It can be done by assigning the event to “Modified On” Change. Also, remember to control function allocation if using methods like addOnChange or addPreSearch, to avoid repeated registration.

A Deeper Look Into Form onLoad Event

Managing the UI based on conditions is a crucial aspect of any web page. With JavaScript, we can invoke a set of codes when a body of a document is loaded using the form onLoad event. This can be paramount in scenarios where settings of certain controls are to be defined, for instance, when the status of an entity is Inactive. JavaScript offers ways to execute either single instructions or a block of code when the form onLoad event is triggered. Therefore, understanding how to invoke and manage these sets of code within the onLoad event after saving is fundamental to providing an effective user experience using JavaScript.

Read the full article MDA: How to invoke the formOnLoad event after saved

Developer Tools - Guide: Triggering formOnLoad Event After Saving in MDA

Learn about MDA: How to invoke the formOnLoad event after saved

Understanding how to set the User Interface (UI) based on unique conditions is fundamental in Microsoft Dynamics 365. For example, when a table's status turns inactive, we often lock all the controls. JavaScript provides the ideal scripting language to enable us to achieve this. Consequently, mastering JavaScript is a practical step you can take to understand this topic adequately.

Microsoft offers a JavaScript learning path, which is beneficial for beginners and intermediate learners. Completing this path ensures that you are comfortable interacting with various UI elements based on certain conditions dynamically. An important aspect of this process involves invoking the formOnLoad event after the form's content is saved.

Understanding the formOnLoad event is vital for our context because it is common to determine how the UI appears based on different states. The formOnLoad event caters for such requirements because you may configure a form to load differently according to a stored state.

Learning how to write efficient functions in JavaScript can be achieved by mastering programing methods that deal with form events. These functions include but are not limited to addOnChange(), addPreSearch(), and similar functions that help you handle form events like onSave() and onLoad(). You can take a course like the JavaScript Essentials course on Udemy to dive deeper into event-driven programming in JavaScript.

Finally, well-structured and maintainable codes are recommended for event handling. Therefore, getting a firm grasp on Code Refactoring – the process of restructuring existing code without changing its output – is essential. Code refactoring techniques ensure the JavaScript code you write is easy to understand, debug, and enhance.

For this purpose, consider enrolling in Udemy's Refactoring in JavaScript course to perfect your code structuring skills. Furthermore, Microsoft has Write cleaner, more maintainable code learning path you can explore.

Also, we have an affiliate program that you could consider joining. You refer students to our courses and earn a commission for each successful referral. The program can be advantageous if you run a tech-blog or manage a coding community. Click on the link to register as an affiliate.

In conclusion, mastering JavaScript and learning how to refactor your code are paramount steps you could take to understand this topic proficiently. Also, by learning how to control events with JavaScript in Microsoft Dynamics 365, you can ensure your code runs smoothly and efficiently to provide an optimal UI experience.

Remember that investing time and resources in upskilling now will bring fruitful results in your career as a developer. Happy Learning!

More links on about MDA: How to invoke the formOnLoad event after saved

MDA: How to invoke the formOnLoad event after saved
Apr 21, 2023 — On form on load event, it is very common to set how the UI looks based on certain conditions. For instance, when the status of the ...
MDA: How to invoke the formOnLoad event after saved
On form on load event, it is very common to set how the UI looks based on certain conditions. For instance, when the status of the entity/table is Inactive,
MDA: How to invoke the formOnLoad event after saved
Apr 21, 2023 — Author: Temmy Wahyu Raharjo, Posted Date: 4/22/2023 4:52:58 AM, Description: On form on load event, it is very common to set how the UI ...


MDA, formOnLoad event, invoke formOnLoad, after save event, MDA formOnLoad, event invocation, MDA save event, formOnLoad after save, trigger formOnLoad MDA, formOnLoad post-save