Skip to main content

Posts

Showing posts with the label vendtable

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; }

Merging Two records

//we will explore how to correct such a situation by merging two records including //all their related transactions. For the demonstration, we will merge two vendor accounts 5001 //and 5002 into a single one, that is, 5001. static void VendAccountMerge(Args _args) { VendTable vendTable; VendTable vendTableDelete; PurchJournalAutoSummary jourSummary; #define.vend('5001') #define.vendDelete('5002') ;      ttsbegin; delete_from jourSummary where jourSummary.VendAccount == #vendDelete; select firstonly forupdate vendTableDelete where vendTableDelete.AccountNum == #vendDelete; select firstonly forupdate vendTable where vendTable.AccountNum == #vend; vendTableDelete.merge(vendTable); vendTable.doUpdate(); vendTableDelete.doDelete();      ttscommit; }

how to create new account to vendtable

void ismailCreateVend() {     VendTable                   vendTable;     EmplTable                   emplTable;     NumberSeq                   numberSeq;     str                         accnum;     ;     ttsbegin;     numberSeq = NumberSeq::newGetNumFromCode(VendParameters::numRefVendAccount().NumberSequence);     vendTable.AccountNum   = numberseq.num();     accnum               ...