Hi Team,
I am working on the InventJournalMovement form in D365FO.
Requirement:
When selecting an Item number from the lookup dropdown, I need the selected product dimensions (Color, Size, Style, Configuration) to autofill automatically based on the selected variant.
Example:
I used the following code in the ItemId modified event:
class TPZ_InventJournalTrans_EventHandler
{
[FormDataFieldEventHandler(
formDataFieldStr(InventJournalMovement, InventJournalTrans, ItemId),
FormDataFieldEventType::Modified)]
public static void ItemId_OnModified(FormDataObject sender, FormDataFieldEventArgs e)
{
FormDataSource inventJournalTrans_ds = sender.datasource();
InventJournalTrans inventJournalTrans = inventJournalTrans_ds.cursor();
InventDim inventDim;
if (inventJournalTrans.ItemId && inventJournalTrans.InventDimId)
{
inventDim = InventDim::find(inventJournalTrans.InventDimId);
if (inventDim)
{
info(strFmt("Selected Item : %1", inventJournalTrans.ItemId));
info(strFmt("InventDimId : %1", inventDim.InventDimId));
info(strFmt("Color : %1", inventDim.InventColorId));
info(strFmt("Size : %1", inventDim.InventSizeId));
info(strFmt("Style : %1", inventDim.InventStyleId));
info(strFmt("Configuration : %1", inventDim.ConfigId));
}
}
}
}
Current Output:
Configuration :
Style :
Size :
Color :
InventDimId : AllBlank
Selected Item : ATBT0023
Issue:
-
During the ItemId modified event, InventDimId is returning AllBlank.
-
Because of this, the selected variant dimensions are not available.
-
I need to get the exact selected variant dimensions immediately after selecting the item from the lookup.
Could anyone suggest:
-
Which event should be used?
-
How to get the selected variant InventDimId correctly?
-
Best approach to autofill Color/Size/Style/Configuration in InventJournalMovement?
Thanks.