Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

How can I print item attributes value

Posted on by 75

Here I need to print item attributes value colour Red and depth and height

Screenshot_5F00_20230516_2D00_172906.jpg

codeunit 50107 ParentChildItem

{

procedure MyProcedure()

var

ItemCard: Record Item;

ItemAttrinuteValue: Record "Item Attribute Value Selection"; begin

ItemCard.SetRange("No.", ItemAttrinuteValue."Inherited-From Key Value");

if ItemCard.FindSet() then repeat 

ItemAttrinuteValue.SetRange("Inherited-From Key Value", ItemCard."No.");

if ItemAttrinuteValue."Attribute Name" = 'Colour' then Message('%1 Parent And Child Items',ItemAttrinuteValue."Attribute Name");

end;

until ItemCard.Next() = 0;

end;

}

This is my. Code my color depth and height is not printed in message what's wrong please help.

  • Shankar Profile Picture
    Shankar 75 on at
    RE: How can I print item attributes value

    If I need to print color for all item no in my message? Only by No passing in set strange will do?

    Want to check that.

  • Shankar Profile Picture
    Shankar 75 on at
    RE: How can I print item attributes value

    Yes ok Thankyou

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How can I print item attributes value

    The id is coming from the mapping table I am not receiving any error please check the item no. What you have passed here.

  • Shankar Profile Picture
    Shankar 75 on at
    RE: How can I print item attributes value

    Hi,as you pass id ? There I am getting error, is it Attribute I'd? Or? Please can you make clear that

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How can I print item attributes value

    Ok, try this now.

     procedure MyProcedure()
        var
            ItemCard: Record Item;
            ItemAttributeValue: Record "Item Attribute Value";
            ItemAttributeValueMapping: Record "Item Attribute Value Mapping";
        begin
            ItemCard.Reset();
            itemcard.SetRange("No.", '1896-S');
            if ItemCard.FindSet() then
                repeat
                    ItemAttributeValueMapping.SetRange("Table ID", DATABASE::Item);
                    ItemAttributeValueMapping.SetRange("No.", ItemCard."No.");
                    if ItemAttributeValueMapping.FindSet() then
                        repeat
                            ItemAttributeValue.reset;
                            ItemAttributeValue.SetRange("Attribute ID", ItemAttributeValueMapping."Item Attribute ID");
                            ItemAttributeValue.SetRange(id, ItemAttributeValueMapping."Item Attribute Value ID");
                            ItemAttributeValue.SetFilter("Attribute Name", '%1', 'Color');
                            if ItemAttributeValue.FindFirst() then begin
                                Message('%1 Parent And Child Items', ItemAttributeValue.Value);
                                exit;
                            end;
                        until ItemAttributeValueMapping.Next() = 0;
                until ItemCard.Next() = 0;
        end;

  • Shankar Profile Picture
    Shankar 75 on at
    RE: How can I print item attributes value

    I tries this still my value is not coming.

  • Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: How can I print item attributes value

    Hi,

    Can you try this functions?

    procedure MyProcedure()
        var
            ItemCard: Record Item;
            ItemAttrinuteValue: Record "Item Attribute Value Selection";
        begin
            ItemCard.Reset();
            itemcard.SetRange("No.",);
            if ItemCard.FindSet() then
                repeat
                    ItemAttrinuteValue.reset;
                    ItemAttrinuteValue.SetRange("Inherited-From Key Value", ItemCard."No.");
                    ItemAttrinuteValue.SetFilter("Attribute Name", '%1', 'Colour');
                    if ItemAttrinuteValue.FindFirst() then
                        Message('%1 Parent And Child Items', ItemAttrinuteValue."Attribute Name");
                until ItemCard.Next() = 0;
        end;
    

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans