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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Open Details form on Header form's OK button click

(0) ShareShare
ReportReport
Posted on by 330

Hi,

Like standard Sales order form, when we click on Create new Sales order button, a header form is opened.

Then after entering values in this form and clicking Ok, another form opens with grid containing Sales order lines but the header has the newly created sales order's information.

I have developed two similar custom forms but when I click on ok button of Header form, the Details form is pointing to a different record.

Please suggest what I missed.

I wrote this code in clicked method of OK button:

FormRun formRun;

Args args = new Args();

args = element.args();

args.name(formStr(DetailsForm));

select headerTable where headerTable.RecId = HeaderTable_ds.object(fieldnum(HeaderTable, RecId)).getValue();

 

args.record(headerTable);

formRun = ClassFactory.formRunClass(args);

formRun.init();

formRun.run();

formRun.detach();

*This post is locked for comments

I have the same question (0)
  • Anton Venter Profile Picture
    20,345 Super User 2025 Season 2 on at

    Hi, do have any code in the details form to filter the records? If not, in the details form, you have to get the header record from the args object and filter the details records using the header ID. This can be done in the executeQuery method of your details form.

  • Verified answer
    Douglas Noel Profile Picture
    3,905 on at

    Hi,

    your code seems to be a little bit strange:

    The new instantiated Args object is never used, because you point it to yout own args afterwards

    ....

    Args args = new Args();

    args = element.args();

    // the created args have no scope/usagereferebce  and can be free'd 

    // your local args variable points to your current form args, so you begin to modify your own args 

    // using this variable from here - this can have a lot of side effects

    ...

    args.name(formStr(DetailsForm)); // your modify your own args name()

    // headerTable seems to be the automatic declared variable for your Datsource record (current record)

    can you please ty the follwing:

    FormRun formRun;

    Args args = new Args(element);  // this will set the caller to the current form

    args.name(formStr(DetailsForm));

    // headerTable is already your current record in your current form so simply pass it

    args.record(headerTable);

    // !!!! yourmain datasource of your calles form should have some relation to the passed record

    // !!!! so that a dynalink could be creted (dynamic filter)

    formRun = ClassFactory.formRunClass(args);

    formRun.init();

    formRun.run();

    formRun.detach();

    regards

    Douglas

  • Yunus Shaik Profile Picture
    330 on at

    Thanks Douglas!

    Its working now.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans