internal final class DaxPurchTableForm_EventHandler
{
/// <summary>
/// </summary>
/// <param name="sender"></param>
/// /// <param name="e"></param>
/// <summary> ///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, PurchTable_Address), FormControlEventType::Lookup)]
public static void PurchTable_Address_OnLookup(FormControl sender, FormControlEventArgs e)
{
PurchTable purchTable;
Query query = new Query();
QueryBuildDataSource dsDirPartyPostalAddressView;
FormRun formRun;
formRun = sender.formRun();
purchTable = formRun.dataSource().cursor();
// Instantiate sysTableLookup object using table which will provide the visible fields
QueryBuildDataSource qbds, qbds2, qbds3;
QueryBuildDataSource QbdsJoin;
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(DirPartyPostalAddressView), sender);
qbds = query.addDataSource(tableNum(DirPartyPostalAddressView));
qbds.addGroupByField(fieldnum(DirPartyPostalAddressView, Address));
qbds.orderMode(OrderMode::GroupBy);
qbds2 = qbds.addDataSource(tableNum(vendtable));
qbds2.addLink(fieldNum(DirPartyPostalAddressView, Party), fieldNum(VendTable, Party));
qbds2.joinMode(JoinMode::ExistsJoin);
qbds2.addRange(fieldNum(vendtable, AccountNum)).value(purchTable.OrderAccount);
sysTableLookup.parmQuery(query);
sysTableLookup.addLookupfield(fieldNum(DirPartyPostalAddressView, Address));
sysTableLookup.performFormLookup();
}
}
....................................................................................................................................................................
How to get vendor location and tax name of vendor by selecting vendor address in lookup
internal final class DaxPurchTableFormAddress_EventHandler
{
/// <summary> ///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
[FormControlEventHandler(formControlStr(PurchTable, PurchTable_Address), FormControlEventType::Modified)]
public static void PurchTable_Address_OnModified(FormControl sender, FormControlEventArgs e)
{
VendTable vendTable;
PurchTable purchTable;
TaxInformation_IN taxInformation_IN;
LogisticsLocation logisticsLocation;
DirPartyTable dirPartyTable;
LogisticsPostalAddress logisticsPostalAddress;
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
FormRun formRun;
formRun = sender.formRun();
FormDataSource purchtable_ds = formRun.dataSource();
purchTable = formRun.dataSource().cursor();
select logisticsPostalAddress where logisticsPostalAddress.Address == purchTable.Address;
select logisticsLocation where logisticsLocation.RecId == logisticsPostalAddress.Location;
select taxInformation_IN
where taxInformation_IN.RegistrationLocation == logisticsLocation.RecId
&& taxInformation_IN.IsPrimary == NoYes::Yes;
ttsbegin;
purchTable.Name = taxInformation_IN.Name;
purchTable.Description = logisticsLocation.Description;
purchTable.selectForUpdate(true);
purchTable.update();
ttscommit;
}
}
......................................................................................................................................
How to update the purchline vendor tax information based on selected vendor address.
My Requirement is to update the purchline vendor tax information. As in previous step select the address from lookup , a dialouge form should be opened. If user click ok address should be updated in purchline line of vendpor tax information. If user click cancel it should not update.
[ExtensionOf(FormDataSourcestr(PurchTable,PurchTable))]
internal final class DaxPurchTableForm_Extension
{
void write()
{
PurchTable purchTable;
PurchLine purchLine;
VendTable vendTable;
TaxInformation_IN taxInformation_IN;
Dialog dialog;
TransTaxInformation transTaxInformationloc;
DialogField field;
next write();
purchTable = this.formRun().dataSource().cursor();
FormDataSource purchTable_ds = this.formRun().dataSource();
vendTable = VendTable::find(purchTable.OrderAccount);
dialog = new Dialog("My Dialog");
dialog.addText("Do you want to save");
dialog.run();
if (dialog.closedOk())
{
while select purchLine where purchLine.PurchId == purchTable.PurchId
{
transTaxInformationloc = TransTaxInformationHelper_IN::findOrCreateTransTaxInformation(purchLine.TableId, purchLine.RecId);
if(transTaxInformationloc)
{
ttsbegin;
transTaxInformationloc.selectForUpdate(true);
TransTaxInformationHelper_IN::initFromCustVend(transTaxInformationloc, vendTable);
transTaxInformationloc.Update();
ttscommit;
}
}
}
}
}
..........................................................................................................................................
If new line created in purchline. A dialouge form should be opened, with ok and cancel buttons.
If user clicks ok, the updated address in purchaseorder header should be populated to current newly created line.If user clicks cancel the purcline vendor tax information should be empty.
[ExtensionOf(formDataSourceStr(PurchTable,PurchLine))]
internal final class DaxPurchTable_Extension
{
void write()
{
PurchTable purchTable;
PurchLine purchLine,purchLineloc,purchLineloc1;
VendTable vendTable;
TaxInformation_IN taxInformation_IN;
Dialog dialog;
TransTaxInformation transTaxInformationloc;
DialogField field;
next write();
FormDataSource purchLine_ds = this.formRun().dataSource();
purchLine = purchLine_ds.cursor();
select purchTable where purchTable.PurchId == purchLine.PurchId;
vendTable = VendTable::find(purchTable.OrderAccount);
if(purchLine.RecId)
{
dialog = new Dialog("My Dialog");
dialog.addText("Do you want to save");
dialog.run();
if (dialog.closedOk())
{
transTaxInformationloc = TransTaxInformationHelper_IN::findOrCreateTransTaxInformation(purchLine.TableId, purchLine.RecId);
if(transTaxInformationloc)
{
ttsbegin;
transTaxInformationloc.selectForUpdate(true); TransTaxInformationHelper_IN::initFromCustVend(transTaxInformationloc, vendTable);
transTaxInformationloc.update();
ttscommit;
}
}
else
{
transTaxInformationloc = TransTaxInformationHelper_IN::findOrCreateTransTaxInformation(purchLine.TableId, purchLine.RecId); if(transTaxInformationloc)
{
ttsbegin;
transTaxInformationloc.selectForUpdate(true);
transTaxInformationloc.VendorLocation =str2Int64("");
transTaxInformationloc.VendorTaxInformation =str2Int64("");
transTaxInformationloc.update();
ttscommit;
}
}
}
}
}