Add Button (save and open new form) on Form EcoResProductCreate

HI all,

I want to add new button on form EcoResProduct with command (SAVE and OPEN NEW FORM),

Can anyone help me how to achieve this .


Use a menu item button to open the new form; AX saves the active record automatically (you can control it through SaveRecord property).
If you meant something else, please elaborate your question.

Hi Martin,

Thanks for your reply,

I have customized the form EcoResProductCreate and I put the button as you can see on attach below with command SAVE and New without closing dialog

What method should I use to achive this.

So what should the button do? I guess you want the same logic as “OK” (so that’s already there) and then opening the same form again, in the same way as if you create a new record in the product (which, I assume, simple means calling the create() method).

Hi Martin,

Thanks again for your help.

The button is the same with the "OK’ as you mentioned with other detail, on the other hand can you send us more detail about this method and where I put this

HI Martin,

Any response regarding my question ?

Thanks for your time and consideration.

I assume that you have a datasource in that form. In that case, simply save the record (or insert) and clear the contents of the entries.

It can be done in multiple ways. Close the form and open it (or) keep the form open, clear the fields and create new.
For doing any thing, first you should understand how the form has been designed? The form doesn’t have any data source. It init the controls while the form opens(look at init method) and maps the controls to the table fields and creates the record on close OK.

Hi Kranthi

Thanks for your reply

Yes I want to use the second way to clear the fields and create new,
Can you tell me what method should I use to clear the fields.


After creating the record, you should probably clear the fields. You have to clear them control by control.
You may also have to call,

Hi Kranithi

I have created a new method for my SaveAndNew button called samiUji() and inside of it I am writing your code but I am getting the following error: "The class ‘FormCommandButtonControl’ does not contain the method ‘initDefaultControlValues’. ".
Where should I write your code you sent to me?
Thanks, I really appreciate your time trying to help me.


If you look at initDefaultControlValues methods, it basically sets the default values for different units.
how you are calling that method? can you show us your code?

I am calling in this way:

private void samiUji()
and I am getting the following error: "The class ‘FormCommandButtonControl’ does not contain the method ‘initDefaultControlValues’. ".

it should be element.initDefaultControlValues(). “This” represents current control

I tried it but i am getting a new error: The method is declared private and may only be called from methods in class FormRun.

Where you have written the method? What changes you made? Can you show us the code?

I have Written the method on Button (Save and New) this code you will see on below

private void samiUji()


What you are going to do with this method?

You should be overriding the clicked method right?


I have overriding the clicked method, but I am getting an error , (the method is declared private and my only be called from methods in class From Run)

void clicked()

if (element.validateWrite())
if (element.write())
closedOK = true;



Which method is causing the error? Don’t worry about the getting the default values by using initDefaultControlValues.
Try focusing on the main issue - to create the new record and clear the values selected on the forum .