web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Clearing fields after saving records

(0) ShareShare
ReportReport
Posted on by 511

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??

I have the same question (0)
  • WillWU Profile Picture
    22,363 on at

    Hi Huggins Mafigu,

    Try to extend the initvalue() method of the Formdatasource, and use the formDataSource.research() method, it might solve your problem.

  • vinitgoyal2005 Profile Picture
    6,332 on at

    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.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    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.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    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!

  • Suggested answer
    Huggins Mafigu Profile Picture
    511 on at

    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.

    Contract.png.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    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.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    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.

  • Suggested answer
    Huggins Mafigu Profile Picture
    511 on at

    Thanks so much. I managed to achieve it by using the following lines after super() in init() method in the form methods.

    MyDataSource_ds.executeQuery();

    MyTable.MyField = '';

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 617

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 298 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans