Ivan Z.
Ivan Z.

Reputation: 23

Axapta - how to update instead of insert

I'm trying to catch an insert on a table and do update instead in some specific cases. How do i go about that? I'm trying to put this in insert method in CustTable table, but i'm not sure where to put the code.

Any ideas?

Thanx, Ivan

Upvotes: 1

Views: 3054

Answers (1)

Jan B. Kjeldsen
Jan B. Kjeldsen

Reputation: 18051

It is bad practice to do updates instead of inserts in the insert method!
Consider the effect on data imports etc.

Consider moving the logic to the CustTable form instead.

This is the way to do it anyway (in the table insert method):

 void insert()
 {
     CustTable t;
     ttsbegin;
     if (<condition>)
     {              
         select forupdate t where ...;
         t.Name = this.Name; // Saving name only
         t.doUpdate();
     }
     else
         super() //does the doInsert()
     ttscommit;
 }

Upvotes: 2

Related Questions