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)

Update a Table in a Form whith another table

(0) ShareShare
ReportReport
Posted on by 630

Hello, I have two tables in a form, Customer and Transaction, when I add a transaction the sum of amount should appear in a field called "Sum" in the table customer. It updates correctly the amount but when I touch the table costumer, how can the first table be updated automatically when I add a transaction?

Thanks, by the way, all the the answers that you have sent to me before have been very helpful!

*This post is locked for comments

I have the same question (0)
  • Pradeep Itnal Profile Picture
    3,248 on at

    try to put your code in linkActive() method.

  • dolee Profile Picture
    11,279 on at

    Hi,

    I assume the Transaction record has to be "saved" before the amount in Customer table should be updated.

    In that case, you can modify the write() method of Transaction_ds, add code there to recalculate related Customer's sum field. At the end, add:

    customer_ds.reread();

    customer_ds.refresh();

    to refresh the customer record.

    Regards

  • Ali Zaidi Profile Picture
    4,657 on at

    You have to implement some code in LinkActive() method, something like following

    public void linkActive()

    {

       ;

       switch(element.args().dataset())

       {

           case tablenum(SalesTable) :

               salesTable = element.args().record();

               break;

           case tablenum(SalesQuotationTable) :

               salesQuotationTable = element.args().record();

               break;

       }

       super();

    }

  • Ulyses Rico Profile Picture
    630 on at

    Ammm, I have applied your suggests but I haven't succed, I'm doing something wrog.

    This is the code I have in the modifyfield method from the transaction table:

    public void modifiedField(FieldId _fieldId)

    {

       GRW_Cliente cliente;

       GRW_TRAN transaccion;

       super(_fieldId);

       if(FieldNum(GRW_TRAN,MontoOriginal) | FieldNum(GRW_TRAN,Moneda)|fieldNum(GRW_TRAN,MontoCalculado))

              {

                  if(this.Moneda!="")

                  {

                    if(this.Moneda==CompanyInfo::standardCurrency())

                     {

                        this.MontoCalculado=transaccion.GRW_calculateTransactionToAccounting(this.Moneda,this.MontoOriginal);

                     }

                    else

                    {

                      this.MontoCalculado=this.MontoOriginal*12.00;

                    }

                      cliente.Saldo =cliente.displayCalculatedBalance();

                 }

       }

    }

    I've written it in the linkmethod but nothing happened. The sum of the balance is right when I move some data from the transaction table, because in the modifiedfield method I said that when the transaction amount is changed a method that calcules the balanced is fired.

    Any help fellows? Thanks!

  • Ulyses Rico Profile Picture
    630 on at

    I also wrote on the datasource methods and no success

  • dolee Profile Picture
    11,279 on at

    In the code you posted, you have:

    cliente.Saldo =cliente.displayCalculatedBalance();

    1) You didn't have any select statement for the Cliente buffer.

    2) You didn't save the cliente buffer after you assign a new value to the Saldo field. You'll need a cliente.update() there.

    Please see if the above help.

    Regards

  • Ulyses Rico Profile Picture
    630 on at

    I addes the cliente.updated() at the end but  it showed me an error, that the record already exists, I also used a cliente.write but it appeared the same error. When I use the linkactive from datasource methods it doesn't work for me because what I want is not to click the table customer to be updated.

  • dolee Profile Picture
    11,279 on at

    Have you add record selection for Cliente before your assignment? Since you are calling the "update" method, normally it shouldn't throw error saying the record already exists. (Because we are suppose to be *updating* an existing record right?)

    For example, if I want to update VendTable (vendor) record, I would do the following.

    ----------------------------------

    ttsbegin;

    // First, select the record I want to update

    select firstonly vendTable

      where vendTable.accountNum == "V001";

    // Then, do the value assignment

    vendTable.name = "new name";

    // Finally, call the update method.

    vendTable.update();

    ttscommit;

    ----------------------------------

    Regards

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