Search code examples
axaptadynamics-ax-2009

Table to be filled automatically in ax 2009


I have a form with HeaderTable and LineTable datasource. HeaderTable contains FromDate and ToDate field and LineTable contains TransactionDate field.

As per the requirement I have to fill the TransactionDate field with 'fromdate' TO 'todate'.

For Example, if HeaderTable contains 1st-Jan & 8th-Jan as fromdate and todate respectively , than in line level it should automatically creates records for 1st to 8th Jan.

I hope it can be done using a button, but not clear. Please suggest with examples.

Thanks. :)


Solution

  • Thanks Jan for replying.

    This is how I solved this problem:

    I created a button, on clicked method of the button I wrote this logic:

    FromDate = Header.FromDate;
    
    while (FromDate <= Header.ToDate)
    {
        Line.InvoiceId = Header.InvoiceId;
        Line.TransactionDate = FromDate;
        Line.doInsert();
        FromDate++;
    
        if (FromDate == Line.TransactionDate)
        {
            break;
        }
    
    }
    
    Line_ds.research(true);
    
    }
    

    Hope this will help someone. Thanks.