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 :
Finance | Project Operations, Human Resources, ...
Answered

Updating/Setting Values of Storage and Tracking Dimension Groups on New Item creation through code

(2) ShareShare
ReportReport
Posted on by 10
Hi, So My requirement is that upon creating a new item, and selecting an item group, a couple fields should get updated with values. I already have a setup form made which had item group and respective field mappings as well. Below is my current code.
 
    [FormControlEventHandler(formControlStr(EcoResProductCreate, ItemGroupId), FormControlEventType::Modified)]
    public static void ItemGroupId_OnModified(FormControl sender, FormControlEventArgs e)
    {
        ItemCreation_GroupSetupTable buffer;
        EcoResTrackingDimensionGroup track;
        EcoResStorageDimensionGroup storage;
        str ItemGroupId = sender.valueStr();
        select * from buffer where buffer.ItemGroup == ItemGroupId;
        select * from track where track.Name == buffer.TrackingDimensionGroup;
        select * from storage where storage.Name == buffer.StorageDimension;
        FormStringControl itemModelGroup = sender.formRun().design().controlName("ModelGroupId");      
        //FormReferenceGroupControl storageDimension = sender.formRun().design().controlName("StorageDimensionGroup");
        //FormReferenceGroupControl trackingDimensionGroup = sender.formRun().design().controlName("TrackingDimensionGroup");
        //FormStringControl storageDimension = sender.formRun().design().controlName("StorageDimensionGroup_Name");
        //FormStringControl trackingDimensionGroup = sender.formRun().design().controlName("TrackingDimensionGroup_Name");
        FormStringControl inventoryUnit = sender.formRun().design().controlName("InventUnitId");
        FormStringControl purchaseUnit = sender.formRun().design().controlName("PurchUnitId");
        FormStringControl saleUnit = sender.formRun().design().controlName("SalesUnitId");
        FormStringControl bomUnit = sender.formRun().design().controlName("BOMUnitId");
        FormStringControl salesTaxation = sender.formRun().design().controlName("SalesTaxItemGroupId");
        FormStringControl purchaseTaxation = sender.formRun().design().controlName("PurchTaxItemGroupId");
        itemModelGroup.text(buffer.ItemModelGroup);
        //storageDimension.value(storage.RecId);
        //trackingDimensionGroup.value(track.RecId);
        //storageDimension.text(buffer.StorageDimension);
        //trackingDimensionGroup.text(buffer.TrackingDimensionGroup);
        inventoryUnit.text(buffer.InventoryUnit);
        purchaseUnit.text(buffer.PurchaseUnit);
        saleUnit.text(buffer.SaleUnit);
        bomUnit.text(buffer.BOMUnit);
        salesTaxation.text(buffer.SalesTaxation);
        purchaseTaxation.text(buffer.PurchaseTaxation);
    }

In the form design, both dimension groups are reference groups control, inside which is a sibling string control.
ive tried updating it by getting ite FormReferenceGroupControl, getting the FormStringControl, but the value isnt updating no matter what i try (The commented out code). and the form doesnt have a data source either.
Please help.
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    Moved from Integration, Dataverse, and general topics forum to Finance | Project Operations, Human Resources, AX, GP, SL forum, because it's clearly about F&O.
     
    Can you confirm that you want your initialization logic to be used only in this form and only if a user manually changes the value of ItemGroupId, not if a product is created by any other means (e.g. by data management), the value comes from a record template or so?
     
    If doing it in the form is correct, an obvious bug is in how you use reference controls. Trying to set values of the replacement string fields is indeed wrong; you need to set values of the reference groups as such. For example, StorageDimensionGroup control needs a RecId of EcoResStorageDimensionGroup table.
  • SA-15031413-0 Profile Picture
    10 on at
    @Martin Dráb, Yes, I only want my logic to work on this form, my entire concern is with this form only, and my only trigger is when a user selects an item group Id on this form.
     
    Now, regarding what you mentioned, as you can see in my code above, I tried the string control approach which worked for all the other fields, but not for the storage dimension group and tracking dimension group, but I have already tried fetching the recid of the related dimension groups and setting the recids in the reference group controls too if you see the commented code which didn't show the value being updated on the form upon selecting item group id either.
    So kindly let me know.
    Thanks.
  • Verified answer
    Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at
    Let me forget your code and use a much easier and safer implementation:
    [ExtensionOf(formStr(EcoResProductCreate))]
    final class EcoResProductCreateMy_Extension
    {
        protected void onItemGroupIdChanged(EcoResProductIdentificationData _identification, ItemGroupId _itemGroupId)
        {
            next onItemGroupIdChanged(_identification, _itemGroupId);
    
            EcoResStorageDimensionGroup storageGroup;
            select firstonly storageGroup; // Just for demo; you'll use your ItemCreation_GroupSetupTable.
    
            this.productData().referenceGroups().parmStorageDimensionGroupRecId(storageGroup.RecId);
        }
    
    }
    It seems to work all right. Please try it.
  • SA-15031413-0 Profile Picture
    10 on at
    @Martin Dráb, Thank you so much, this worked.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

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

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 473

#3
Adis Profile Picture

Adis 284 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans