Tuesday, January 31, 2023

How to get vendor name of a purchase order in lookup from logisticslocation using X++

 [FormControlEventHandler(formControlStr(PurchTable, PurchTable_Description), FormControlEventType::Lookup)]   

public static void PurchTable_Description_OnLookup(FormControl sender, FormControlEventArgs e) 

{        

VendTable    vendTable;        

PurchTable  purchTable,purchTable1; 

TaxInformation_IN    taxInformation_IN;        

LogisticsLocation    logisticsLocation;                

 DirPartyTable  dirPartyTable;        

TaxInformationName  tax;        

str name1;           

FormStringControl Name;        

Query query = new Query();        

QueryBuildDataSource queryBuildDataSource;        

QueryBuildRange queryBuildRange;        

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(LogisticsLocation), sender);        

FormRun formRun;        

formRun = sender.formRun();        

purchTable  = formRun.dataSource().cursor();        

vendTable= vendTable::find(purchTable.OrderAccount);        

dirPartyTable = DirPartyTable::findRec(vendTable.Party);        

logisticsLocation = LogisticsLocation::find(dirPartyTable.PrimaryAddressLocation);        

taxInformation_IN = TaxInformation_IN::findDefaultbyLocation(logisticsLocation.RecId);          

queryBuildDataSource = query.addDataSource(tableNum(TaxInformation_IN));        

sysTableLookup.addLookupField(fieldNum(LogisticsLocation,Description));          

queryBuildRange = queryBuildDataSource.addRange(fieldNum(LogisticsLocation,RecId));        

queryBuildRange.value(SysQuery::value(tlogisticsLocation.RecId));        

sysTableLookup.parmQuery(query);        

sysTableLookup.performFormLookup();    

}

No comments:

Post a Comment