Categories
NAV 2017 (10) Reminder

Add new fields on Item Template Card

This post describe about how to add new fields into Item Template card.

In NAV 2017, there is a Template feature, for  example in Item card.

We can setup the Template, with the default value we want to fill the master card with. For example: for Retail items, the Gen. Prod. Posting Group is RETAIL, while for Manufactured items, must be MANUFACT.

Then, each time we create a new item card, we can fill those fields with the default values, based on the template card. Saves time, and reduce human error as well.

But, the fields are limited. Luckily, we can extend the functionality by adding the new fields we need.

This is how:

PS. This walkthrough is only applied to Item Template, but should be work in the other templates in the same logic.

  1. On Item Template table (301), design, and add new fields you want, e.g. Item Tracking Code and Lot Nos. Add too on Item Template Card page (1342). Notice that the fields ID must be the same as the master table’s ID, i.e. 6500 for Item Tracking Code, and 6501 for Lot Nos. Tip: you can look Item table (27) for the fields ID.
  2. On CreateFieldRefArray function, add a new line of code for each a new field added. So, in my example, I must add 2 lines of code, mentioning the new field name: AddToArray(FieldRefArray,I,RecRef.FIELD(FIELDNO(“Item Tracking Code”)));
    AddToArray(FieldRefArray,I,RecRef.FIELD(FIELDNO(“Lot Nos.”)));
  3. Since FieldRefArray variable is using array, so we must enlarge the array dimensions on some of these functions (both parameters or local variables). Since I add 2 new fields, then I must change the array dimension from 17 to 19.
    1. OnInsert()
    2. OnModify()
    3. CreateFieldRefArray
    4. AddToArray
    5. CreateConfigTemplateFromExistingItem
    6. InsertConfigurationTemplateHeaderAndLines

This way, you can setup the default values for Item Tracking Code and Lot Nos. on your template card, then will be populated automatically when you apply the template.

4 replies on “Add new fields on Item Template Card”

This particular solution for standard fields in T27 Item is only partially true. Field “Item Tracking Code” has fieldno 6500 and I don’t think you can create that same field in T1301 “Item Template” with that field number. Mine for example is at fieldno 11225045.
In C8612 “Config. Template Management” (and other places too) you have to change code in:

//ConfigTemplateLine.SETFILTER(“Field ID”,’=%1′,FieldRef.NUMBER); A108F0092.o
ConfigTemplateLine.SETRANGE(“Field ID”,ItemTemplateMgt.GetActualFieldID(FieldRef,TableID,FieldRef.NUMBER)); //A108F0092.n

GetActualFieldID2(FromTableID : Integer;ToTableID : Integer;FieldID : Integer) : Integer
CASE TRUE OF
(FromTableID = DATABASE::”Item Template”) AND (ToTableID = DATABASE::Item):
WITH ItemTemplate DO BEGIN
CASE FieldID OF
FIELDNO(“Item Tracking Code”):
EXIT(Item.FIELDNO(“Item Tracking Code”));
FIELDNO(“Lot Nos.”):
EXIT(Item.FIELDNO(“Lot Nos.”));
FIELDNO(“Serial Nos.”):
EXIT(Item.FIELDNO(“Serial Nos.”));
END;
END;
(FromTableID = DATABASE::Item) AND (ToTableID = DATABASE::”Item Template”):
WITH Item DO BEGIN
CASE FieldID OF
FIELDNO(“Item Tracking Code”):
EXIT(ItemTemplate.FIELDNO(“Item Tracking Code”));
FIELDNO(“Lot Nos.”):
EXIT(ItemTemplate.FIELDNO(“Lot Nos.”));
FIELDNO(“Serial Nos.”):
EXIT(ItemTemplate.FIELDNO(“Serial Nos.”));
END;
END;
END;
EXIT(FieldID);

Liked by 1 person

Leave a comment