Search code examples
axaptadynamics-ax-2012x++

Update multiple records in same table


I want to update multiple SalesQuotationLines the match Quotation Id X.

salesQuotationLine = salesQuotationLine::find(quotationId,true);

salesQuotationLine.selectForUpdate(true);

if(salesQuotationLine) {

 ttsBegin;

SalesQuotationLine.Field = newFieldValue;
salesQuotationLine.update();

ttscommit;

The problem is, this is only updating the first record that is found within the find method.

How can I make sure, all records that match the QuotationID are being updated?


Solution

  • you can use this code:

    while select forupdate salesQuotationLine 
    where salesQuotationLine.quotationId == quotationId 
    {
        salesQuotationLine..Field = newFieldValue;
        ttsbegin;
        salesQuotationLine.update();
        ttscommit;
    }
    

    Or can Use _update_recordset_

    ttsbegin;
    update_recordset salesQuotationLine
    setting
    Field = newFieldValue
    where salesQuotationLine.quotationId == quotationId 
    ttscommit;
    

    I hope to understock the question.