Skip to main content

Posts

Showing posts with the label update

How to update vendor addresses in Dynamics AX 2009

static void  UpdateVendAddressType(Args _args) { VendTable      vendTab; // Replace VendTable with CustTable when run this for  customers. DirPartyTable dirPartyTab; Address           addTab; ; ttsbegin; while select vendTab join dirPartyTab join forupdate addTab where vendTab.PartyId == dirPartyTab.PartyId && addTab.AddrTableId == dirPartyTab.TableId && addTab.AddrRecId == dirPartyTab.RecId {       if(addTab.Name == ‘Birincil Adres’)      {         addTab.type = AddressType::Payment;         addTab.update();      } } ttscommit; }

Updating the caller Form/DataSource

void updateCaller() { Common common; Object dataSource; Object caller; ; //----------------------------------- //We are notifying using the dataSource common = element.args().record(); if (common && common.isFormDataSource() && formDataSourceHasMethod(common.dataSource(), identifierstr(SomethingWasHappend))) { dataSource = common.dataSource(); dataSource.SomethingWasHappend(); } //----------------------------------- //----------------------------------- //We are notifying using the form caller = element.args().caller(); if (caller && classidget(caller) == classnum(SysSetupFormRun) && formHasMethod(caller, identifierstr(SomethingWasHappend))) { caller.SomethingWasHappend(); } //----------------------------------- } Implement the handling method in the parent form: void SomethingWasHappend() { ; info("Something was ha...

Update all records shown in a form

If you want to update, or do something else, with all records shown on a form (i e only the records shown by the filter), you can use the following code. In the example below, CustTable is used as example. void updateRecords() { CustTable custTableLocal; QueryRun queryRun; ; queryRun = new QueryRun(CustTable_DS.queryRun().query()); while (queryRun.next()) { if (queryRun.changed(tableNum(CustTable))) { custTableLocal = queryRun.get(tableNum(CustTable)); // DO STUFF } } }