Print Item Attributes on Report

In Dynamics NAV 2017 a cool new feature, called Item Attributes, was introduced.
I makes it possible to invent your own attributes for Items, instead of creating fields i Item table. This feature is well known in PIM systems.

But how do you collect a list of all attributes on a Item, to print on a Report.

Create 4 Global variables
2

Create a DataItem as a child to the DataItem holding your Item No. and point it to Item Attribute Value Mapping table (7505), and add the 2 global text variables.
1

Add the following code to the DataItem, and add the 2 textvariables to a repeater tablix in RDCL.

ItemAttributeValueMapping - OnPreDataItem()
 ItemAttributeValueMapping.SETRANGE("Table ID", DATABASE::Item);
 ItemAttributeValueMapping.SETRANGE("No.", "Sales Line"."No.");

IF NOT ItemAttributeValueMapping.FINDSET THEN
 CurrReport.BREAK;

ItemAttributeValueMapping - OnAfterGetRecord()
CLEAR(ItemAttributeText);
CLEAR(ItemAttributeValueText);

IF ItemAttributeValue.GET(ItemAttributeValueMapping."Item Attribute ID", ItemAttributeValueMapping."Item Attribute Value ID") THEN BEGIN
 ItemAttributeValueText := ItemAttributeValue.GetTranslatedName(CurrReport.LANGUAGE);
 IF ItemAttributeValueText > '' THEN BEGIN
    IF ItemAttribute.GET(ItemAttributeValueMapping."Item Attribute ID") THEN BEGIN
      ItemAttributeText := ItemAttribute.GetTranslatedName(CurrReport.LANGUAGE);
      ItemAttributeValueText := ItemAttributeValueText + ' ' + ItemAttribute."Unit of Measure";
    END;
  END ELSE BEGIN
    CurrReport.BREAK;
  END;
END;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s