Get the last transaction date for a vendor using X++

Hi,

Can you please help on how to get the last transcation date for a vendor using X++.

Regards,

Look into VendTrans by doing a sort on TransDate.

For reference see, \Data Dictionary\Tables\VendTable\Methods\lastPaymentDate

Hi bharath,

The below X++ code will help you perfectly.

static void lasttransdate(Args _args)
{
VendTable vendtable;
VendTrans vendtrans;
DirPartyTable dirptab;
;
while select vendtable
{
select firstOnly vendtrans
order by vendtrans.TransDate desc
join dirptab
where vendtrans.AccountNum == vendtable.AccountNum && dirptab.RecId == vendtable.Party;
{
if(vendtrans)
{
info(strFmt("Name: %1,LastTransDate: %2 ",dirptab.Name,vendtrans.TransDate));
}
}

Regards,

Jacob.A