web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

How to Autofill Selected Product Dimensions in InventJournalMovement Form Using X++

(0) ShareShare
ReportReport
Posted on by 52

 

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:

  • If user selects ATBT0023 : COLOR : RED
    → Color field should display RED

  • If user selects ATBT0023 : COLOR : BLUE
    → Color field should display BLUE

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:

  1. Which event should be used?

  2. How to get the selected variant InventDimId correctly?

  3. Best approach to autofill Color/Size/Style/Configuration in InventJournalMovement?

Thanks.

I have the same question (0)
  • Martin Dráb Profile Picture
    239,507 Most Valuable Professional on at
    Moved from Integration, Dataverse, and general topics forum.
     
    Your code assumes that InventDimId somehow populated automatically after you selected an item and before your code executed. But you've proven that this assumption isn't correct.
     
    Can you tell us more about your business scenario? You said that you've selected a particular variant and you want to get its InventDimId, but it seems to me that you've selected an item ID only.
  • Roja C-30061119-0 Profile Picture
    52 on at

    Thank you for the clarification.

    In my scenario, I am selecting only the ItemId from the lookup in the InventJournalMovement form, not directly selecting InventDimId.

    However, the Item lookup itself displays the product variants and dimensions. As shown in the screenshot below, the lookup contains values like:

    • ATBT0023 : COLOR : BLUE

    • ATBT0023 : COLOR : BLACK

    • ATBT0023 : COLOR : RED

    So even though I am selecting the ItemId, the user is effectively choosing a specific variant/color from the lookup.

    My requirement is:
    When the user selects one of these rows from the lookup, I want the corresponding product dimensions (Color, Size, Style, Configuration) to autofill automatically in the journal line.

    Current Issue:
    During the ItemId modified event:

    • InventDimId is returning AllBlank

    • Color/Size/Style/Configuration are empty

    • It seems the selected variant dimensions are not yet assigned at that stage

    Example:
    If I select:
    ATBT0023 : COLOR : RED

    Expected Result:

    • Color = RED

    But currently:

    • InventDimId = AllBlank

    Please see the attached screenshot for reference.

    Could anyone suggest:

    1. How to capture the selected variant from this lookup?

    2. Which event/method should be used to get the correct dimensions?

    3. Best approach to autofill product dimensions in InventJournalMovement?

    Thank you.

  • Martin Dráb Profile Picture
    239,507 Most Valuable Professional on at
    By the way, you're making a big mistake by ignoring all standard logic of the form. At best, you'll design solution that is hard to understand and maintain. But very likely, your logic will break important standard logic.
     
    In the case, notice that InventJournalMovement form calls InventJournalFormController_Movement class in many cases, such as when any line field changes. That also uses InventJournalFormTrans_Movement class, where you can find important logic such as defaulting based on item ID or validation of inventory dimensions.
  • Martin Dráb Profile Picture
    239,507 Most Valuable Professional on at
    What form is the lookup form from your screenshot?
     
    In my environment, the movement journal uses InventItemIdLookupSimple form, which doesn't have inventory dimensions.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 131 Super User 2026 Season 1

#2
Laurens vd Tang Profile Picture

Laurens vd Tang 98 Super User 2026 Season 1

#3
Zain Mehmood Profile Picture

Zain Mehmood 89 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans