Announcements
No record found.
I have created a form with a custom pattern in D365FO and have attached data source fields to the form. When I create a new record using the form, it does not clear the fields. My question is how do I clear those fields??
Hi Huggins Mafigu,
Try to extend the initvalue() method of the Formdatasource, and use the formDataSource.research() method, it might solve your problem.
hi,
what do you mean by it does not clear the fields? Have you used the grid to display the data? Did you assign the data source to the grid in properties? Share your screenshots so it is easier to understand what you have done already.
Hi Huggins,
Why are you looking to clear the values? You can close the form and use it to create a new record again. I am assuming that you will be using the same form to edit records as well.
You can look at the Vendors form (VendTable) as an example.
Normally if you have a separate dialog for creating new records (for example Sales order creation is such example in the standard application) the dialog is closed when user clicks OK and the order is created. So there's no need to clear any fields.
But, if you want to keep your form open, you need to clear the fields in code.
If you use a temp table behind your form, you can just clear the buffer. But if your fields are not bound to any data source, you must clear all of them separately.
Perhaps I don't understand your question. Could you share all details about your form, and add some screenshots to help us understand? Thanks!
No I'm not using a dialog form. This is the form. So what I want is to clear the fields after saving the fields and to clear the fields after opening the form. Right now when I open the form it's opening with fields loaded with data.
NOTE: The controls are attached to the Data source fields.
.
Normally when you open a form it shows a record from the database.
If you want it to always create a new record (with empty fields) when opening the form, you must do so in the init method of the form (when the form is opened).
You can try to call MyDataSource_ds.create() after the super() call in the init method.
But this is not about "clearing fields", it's about which record should be active in the data source.
If you are opening this form for new records for another form, you can create a new menu item and set the Enum Type parameter to "FormOpenMode" and Enum Parameter to "ForNew".
For an example, please check the menu item VendTableNew which is set on VendTableListPage.
Thanks so much. I managed to achieve it by using the following lines after super() in init() method in the form methods.
super()
init()
MyDataSource_ds.executeQuery();
MyTable.MyField = '';
That doesn't sound like the correct solution. If you would now click Save, it would update the record that was active in the data source. Unless that's what you want.
The suggestion related to FormOpenMode is the correct one here.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
Congratulations to our 2026 Super Stars!
Thanks to all of our 2025 Community Spotlight stars!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Giorgio Bonacorsi 617
André Arnaud de Cal... 461 Super User 2026 Season 1
Syed Haris Shah 298 Super User 2026 Season 1