Sending Custom Fields from PurchParmLine to VendPackingSlipTrans in D365 FO

Hey Learners!

In this article, we will learn how to create custom fields in PurchParmLine and VendPackingSlipTrans, and send the data to VendPackingSlipTrans upon product receipt creation.

We will be using the concept of Chain of Command here, in order to populate the custom field specially in VendPackingSlipTrans.

The custom field I am adding in both tables is "ProductionLot".

Step 01: Create Table Extension

Create extensions of PurchParmLine and VendPackingSlipTrans to add the custom field. Change the field name as per your requirement, here it will be a string field named as "ProductionLot" with label set to "Lot Id".

Step 02: Create PurchEditLines Form Extension

Create extension of form "PurchEditLines", find your custom field and add the field to the grid "gridParmLine". In this case, my string field was needed to be a lookup field, the data in the lookup is taken from a custom table 'ProductionLotSetupTable'. To make it a lookup field we will be creating an extension class of this form and copying the "onlookup" eventhandler of this field.

[ExtensionOf(formstr(PurchEditLines))]

final class PurchEditLines_Extension

{

/// <summary>

///

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

[FormControlEventHandler(formControlStr(PurchEditLines, PurchParmLine_ProductionLot), FormControlEventType::Lookup)]

public static void PurchParmLine_ProductionLot_OnLookup(FormControl sender, FormControlEventArgs e)

{

Query query = new Query();

QueryBuildDataSource queryBuildDataSource;

LotIdSetupTable LotIdtable;

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

sysTableLookup.addLookupField(fieldNum(LotIdSetupTable, ProductionLot));

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

//records with the active status will appear in the lookup

queryBuildDataSource.addRange(fieldNum(LotIdSetupTable, Status)).value(SysQuery::value(ActiveStatusEnum::Active));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

}

Step 03: Create PurchPackingSlipJournalCreate Class Extension

The last step is to write a PurchPackingSlipJournalCreate class extension. Here the concept of chain of command is used, we will be using the initJournalLine method of this class to send the PurchParmLine custom field's data to VendPackingSlipTrans.

[ExtensionOf(classStr(PurchPackingSlipJournalCreate))]

final class PurchPackingSlipJournalCreate_Extension

{

public Common initJournalLine(Common _parmLine)

{

PurchParmLine purchParmLine = _parmLine as PurchParmLine;

VendPackingSlipTrans vendPackingSlipTrans = next initJournalLine(purchParmLine);

vendPackingSlipTrans.ProductionLot = purchParmLine.ProductionLot;

return vendPackingSlipTrans;

}

}

Conclusion

By following these steps carefully, you’ll be able to transfer custom fields between PurchParmLine and VendPackingSlipTrans seamlessly in Dynamics 365.

To view or add a comment, sign in

More articles by Syeda Alishba Nasir

Insights from the community

Others also viewed

Explore topics