How to use Field Modified in Datasource in ax D365
How to use Field Modified in Datasource in ax D365
Here we are going to use Modified in item field in form datasource.
form-> salestable -> Ds-> salesline -> itemid-> event-> modified -> copy event.
create new class
Paste event in this class
Call datasource.
FormDataSource SalesLine_ds = sender.dataSource();
SalesLine SalesLine = SalesLine_ds.cursor();
class Aks_NetAmtBasedonGivenDisc
{
[FormDataFieldEventHandler(formDataFieldStr(SalesTable, SalesLine, ItemId), FormDataFieldEventType::Modified)]
public static void ItemId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
EcoResCategory
ecoResCategory;
InventTable
inventTable;
EcoResProductCategory
ecoResProductCategory;
EcoResCategoryHierarchy
ecoResCategoryHierarchy;
InventOnhand
inventOnHand;
InventDimParm inventDimParm;
InventQty
availQty;
InventDim
inventdim;
//ItemId itemid;
SalesTable
salestable;
real Amount,amt1;
Tax
tax;
FormDataSource SalesLine_ds = sender.dataSource();
SalesLine SalesLine = SalesLine_ds.cursor();
ItemId ItemId = sender.getValue(0);
select InventTable
where inventTable.ItemId == ItemId;//SalesLine.ItemId;
while select ecoResProductCategory
where ecoResProductCategory.Product == inventTable.Product
join ecoResCategoryHierarchy
where ecoResCategoryHierarchy.RecId ==
ecoResProductCategory.CategoryHierarchy
&&
ecoResCategoryHierarchy.Name == "Retail Product
Category"
{
select ecoResCategory
where ecoResCategory.RecId == ecoResProductCategory.Category;
SalesLine.God_AllowedDiscount =
ecoResCategory.GOD_AllowedDiscount;
}
Amount = Tax::calcTaxAmount(SalesLine.TaxGroup,SalesLine.TaxItemGroup,systemDateGet(),SalesLine.CurrencyCode,SalesLine.LineAmount,TaxModuleType::Sales);
SalesLine.Aks_TotalAmoutWithVAT =
SalesLine.LineAmount + Amount;
}
}
Thanks
Akshay
No comments:
Post a Comment