Purpose: The purpose of this document is to demonstrate how we can we Update purchparmline quantity field through code
Product:
Dynamics 365 for Finance and Operations.
Development approach:
Customization through CODE, we need to update receive now with remain after field from purch edit line form . user wants to update set of lines at a time insted of changing all lines individually.
Development:
Create a button , when user click on button with selected all line will update recive now quantity with remainafter values.
[Extensionof(FormDataSourcestr(PurchEditLines, PurchParmTable))]
internal final class PurchEditLinesForm_Extension
{
[FormControlEventHandler(formControlStr(PurchEditLines, DefaultRemainderQuantity), FormControlEventType::Clicked)]
public static void DefaultRemainderQuantity_OnClicked(FormControl sender, FormControlEventArgs e)
{
FormRun fr = sender.formRun();
FormDataSource purchparmline_ds = fr.dataSource(formDataSourceStr(PurchEditLines, PurchParmLine)) as FormDataSource;
MultiSelectionHelper selectionHelper = MultiSelectionHelper::construct();
Set selectedRecords = new Set(Types::Record);//Declare a set of type record
PurchParmLine tableLines;
selectionHelper.parmDataSource(PurchParmLine_DS);
tableLines = selectionHelper.getFirst();
if (tableLines.RecId)
{
while (tableLines)
{
selectedRecords.add(tableLines);
ttsbegin;
tableLines.ReceiveNow = tableLines.RemainAfter;
tableLines.RemainAfter = tableLines.RemainBefore - tableLines.ReceiveNow;
tableLines.doUpdate();
ttscommit;
tableLines = selectionHelper.getNext();
}
PurchParmLine_DS.research();
PurchParmLine_DS.refresh();
}
}
}
Form:Purch edit lines
Comments
Post a Comment