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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to add a new record in a related table from a form

(0) ShareShare
ReportReport
Posted on by 30

Hello, 

I'm working in AX 2012 R3.

I'm updating the BatchJob Form.

I created a second table to add more fields to the BatchJob table.

The second table relates to BatchJob with relationshiptype = Composition.

In the form I have 2 datasources one for BatchJob and another for BatchJob_Extend table.

The BatchJob_Extend datasource has Batchjob as join datasource of type OuterJoin.

I then modified the grid to show fields from the new Batchjob_Extend table.

When I tried to modify a field in the new table and I move out of the record I get an error: "Field 'Reference' must be filled in.

If I play around with the join source settings I can get the records to be inserted but then the form doesn't load the data properly for the new fields.

Any help would be appreciated.

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Carlo,

    You can override write method in the Batchjob_Extend datasource and populate the field using which you have linked it to BatchJob table.

    public void write()
    {
        if (!batchJob_Extend.BatchJob)
        {
            batchJob_Extend.BatchJob = batchJob.RecId; 
        }
        
        super();
    }

    This way the reference field will be populated in the new record.

  • Carlo T Profile Picture
    30 on at

    Thank you GunJan.

    I had to modify your suggestion and I ended up overwriting the ValidateWrite method in the datasource you recommend. I guess the sequence of events on the form was validating before doing the actual writing.

  • Carlo T Profile Picture
    30 on at

    Hi again.

    It's there a way to stop the form to try to create the new record in BatchJob_Extend when I create a new record in BatchJob?

    When I create the record I still have the same problem of missing reference but the BatchJob.RecId is still empty

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi Carlo,

    I think it will be best for you to use table extension framework for this. Please check this post for an example of how to do this.

    You can also check tables SalesLine and SalesLine_IN which have been designed in the same way.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans