Skip to main content

Notifications

Dynamics 365 Community / Forums / Finance forum / Display product attrib...
Finance forum
Suggested answer

Display product attributes in a form

Posted on by 4
Hi Experts, 

I have a requirement to add specifically 3 product attributes in numerous forms (Sales lines, Released products etc. ) next to item numbers. I don't want to add it like a display field as the users must be able to filter them in the forms. What is the best way to achieve it ? any help would be much appreciated. I found below code to get the attributes for an item. I am thinking to create a view for the same but just wanted to be sure that there is no other better way to get it done and the view should work. 
 
static void Demo_GetProductAttributes(Args _args)
{
    inventTable                 InventTable;
    EcoResProductAttributeValue ecoResProductAttributeValue;
    EcoResAttribute             ecoResAttribute;
    EcoResValue                 ecoResValue;

    while select InventTable where InventTable.itemid == "1604"
        join RecId from ecoResProductAttributeValue
        where ecoResProductAttributeValue.Product == InventTable.Product
            join Name from ecoResAttribute
            where ecoResProductAttributeValue.Attribute == ecoResAttribute.RecId
                join ecoResValue
                where ecoResValue.RecId == ecoResProductAttributeValue.Value
    {
        info(strFmt("%1 - %2 - %3", InventTable.ItemId, ecoResAttribute.Name, ecoResValue.value()));
    }
}
  • Suggested answer
    Saif Ali Sabri Profile Picture
    Saif Ali Sabri 32 on at
    Display product attributes in a form

    1. Create a View

    Creating a view that combines the relevant tables is a good approach. This way, you can easily join InventTable, EcoResProductAttributeValue, EcoResAttribute, and EcoResValue to fetch the attributes you need. This will allow you to display them alongside item numbers in the grid and provide filtering capabilities.

    Steps to Create the View

    1. Create a View in AOT:

      • Navigate to the AOT, right-click on Views, and create a new view.
      • Add the required data sources (e.g., InventTable, EcoResProductAttributeValue, etc.) and set up the joins as per your requirement.
    2. Define the Fields:

      • Include the fields you want to display in the form, including the product attributes.
    3. Implement Filtering:

      • Make sure the view allows filtering on the fields you have included. This typically means ensuring the fields are indexed properly.

    2. Modify the Form

    Once you have your view created, you can modify the forms where you want to display these attributes:

    1. Add the View as a Data Source:

      • In the form's data sources, add your newly created view.
    2. Design the Layout:

      • Place the necessary fields in the layout next to the Item Number field.
    3. Filtering Logic:

      • Ensure the filtering mechanism works correctly. This can be achieved by setting the appropriate properties for the fields (e.g., AllowEdit, AllowFiltering).

     

    Using a view is typically the best practice for this requirement, as it centralizes the logic for retrieving product attributes and allows for easy filtering. Make sure to test the performance of the view, especially if you're working with a large dataset, and implement any necessary indexing for optimal performance.

  • Suggested answer
    Saif Ali Sabri Profile Picture
    Saif Ali Sabri 32 on at
    Display product attributes in a form
    ItemId Existence: Verify that an item with ItemId = "1604" exists OR  it might be due to missing relationships in the data.
  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 290,782 Super User 2024 Season 2 on at
    Display product attributes in a form
    foHi,

    I concur with Martin. However, be aware of possible performance issues. You can check if there are already views available similar to what you need. 

    What is the exact purpose of these fields? Depending on the requirements, you can also consider creating physical fields.
     
  • Martin Dráb Profile Picture
    Martin Dráb 229,067 Most Valuable Professional on at
    Display product attributes in a form
    I think that creating a view is the best approach in your case.

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

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,782 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,067 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,150

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans