web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

How to Add the record in Item Table with template?

(0) ShareShare
ReportReport
Posted on by 2,304 Moderator

So, I have created my "custom template" and selected that template in my set parameter form, now the requirement is to create the item only giving the description as input, and all the other fields should not be visible to the user and populate from my "service template" that I have set in my set parameter form.

I have created the template and I can fetch my "custom template" data...

procedure txtDefault()
    var
        CreateItem: Record Item;
        ItemTempl: Record "Item Templ.";
        setupTable: Record myParameterTable;

    begin
        ItemTempl.reset;
        setupTable.Get();
        ItemTempl.Code := setupTable.ItemTemplate;
        if ItemTempl.Find('=') then begin
            CreateItem.Init();
            CreateItem."Base Unit of Measure" := ItemTempl."Base Unit of Measure";
            CreateItem."Price Unit Conversion" := ItemTempl."Price Unit Conversion";
            CreateItem.Type := ItemTempl.Type;
            CreateItem."Inventory Posting Group" := ItemTempl."Inventory Posting Group";
            CreateItem."Shelf No." := ItemTempl."Shelf No.";
            CreateItem."Item Disc. Group" := ItemTempl."Item Disc. Group";
            CreateItem."Allow Invoice Disc." := ItemTempl."Allow Invoice Disc.";
            CreateItem."Statistics Group" := ItemTempl."Statistics Group";
            CreateItem."Commission Group" := ItemTempl."Commission Group";
            CreateItem."Unit Price" := ItemTempl."Unit Price";
            CreateItem."Price/Profit Calculation" := ItemTempl."Price/Profit Calculation";
            CreateItem."Profit %" := ItemTempl."Profit %";
            CreateItem."Costing Method" := ItemTempl."Costing Method";
            CreateItem."Unit Cost" := ItemTempl."Unit Cost";
            CreateItem."Standard Cost" := ItemTempl."Standard Cost";
            CreateItem."Indirect Cost %" := ItemTempl."Indirect Cost %";
            CreateItem."Vendor No." := ItemTempl."Vendor No.";
            CreateItem."Vendor Item No." := ItemTempl."Vendor Item No.";
            CreateItem."Lead Time Calculation" := ItemTempl."Lead Time Calculation";
            CreateItem."Reorder Point" := ItemTempl."Reorder Point";
            CreateItem."Maximum Inventory" := ItemTempl."Maximum Inventory";
            CreateItem."Reorder Quantity" := ItemTempl."Reorder Quantity";
            CreateItem."Unit List Price" := ItemTempl."Unit List Price";
            CreateItem."Duty Due %" := ItemTempl."Duty Due %";
            CreateItem."Duty Code" := ItemTempl."Duty Code";
            CreateItem."Gross Weight" := ItemTempl."Gross Weight";
            CreateItem."Net Weight" := ItemTempl."Net Weight";
            CreateItem."Units per Parcel" := ItemTempl."Units per Parcel";
            CreateItem."Unit Volume" := ItemTempl."Unit Volume";
            CreateItem.Durability := ItemTempl.Durability;
            CreateItem."Freight Type" := ItemTempl."Freight Type";
            CreateItem."Tariff No." := ItemTempl."Tariff No.";
            CreateItem."Duty Unit Conversion" := ItemTempl."Duty Unit Conversion";
            CreateItem."Country/Region Purchased Code" := ItemTempl."Country/Region Purchased Code";
            CreateItem."Budget Quantity" := ItemTempl."Budget Quantity";
            CreateItem."Budgeted Amount" := ItemTempl."Budgeted Amount";
            CreateItem."Budget Profit" := ItemTempl."Budget Profit";
            CreateItem.Blocked := ItemTempl.Blocked;
            CreateItem."Block Reason" := ItemTempl."Block Reason";
            CreateItem."Price Includes VAT" := ItemTempl."Price Includes VAT";
            CreateItem."VAT Bus. Posting Gr. (Price)" := ItemTempl."VAT Bus. Posting Gr. (Price)";
            CreateItem."Gen. Prod. Posting Group" := ItemTempl."Gen. Prod. Posting Group";
            CreateItem."Country/Region of Origin Code" := ItemTempl."Country/Region of Origin Code";
            CreateItem."Automatic Ext. Texts" := ItemTempl."Automatic Ext. Texts";
            CreateItem."Tax Group Code" := ItemTempl."Tax Group Code";
            CreateItem."VAT Prod. Posting Group" := ItemTempl."VAT Prod. Posting Group";
            CreateItem.Reserve := ItemTempl.Reserve;
            CreateItem."Global Dimension 1 Code" := ItemTempl."Global Dimension 1 Code";
            CreateItem."Global Dimension 2 Code" := ItemTempl."Global Dimension 2 Code";
            CreateItem."Stockout Warning" := ItemTempl."Stockout Warning";
            CreateItem."Prevent Negative Inventory" := ItemTempl."Prevent Negative Inventory";
            CreateItem."Item Category Code" := ItemTempl."Item Category Code";
            CreateItem."Manufacturing Policy" := ItemTempl."Manufacturing Policy";
            CreateItem."Reordering Policy" := ItemTempl."Reordering Policy";
            CreateItem."Item Tracking Code" := ItemTempl."Item Tracking Code";
            CreateItem."Lot Nos." := ItemTempl."Lot Nos.";
            CreateItem."Serial Nos." := ItemTempl."Serial Nos.";
            CreateItem."Warehouse Class Code" := ItemTempl."Warehouse Class Code";
            CreateItem."Special Equipment Code" := ItemTempl."Special Equipment Code";
            CreateItem."Put-away Template Code" := ItemTempl."Put-away Template Code";
            CreateItem.Description := 'Description Final Testing two';
            CreateItem.Insert(true);
            Message('Item Added');
        end;

But the problem is that I have to map all the fields from my template, I'm not sure If I'm doing it right, is there any other shortcut way like using the system's code unit procedure instead of writing all it down? I've tried debugging the process but couldn't find which procedure of CodeUnit "Item Templ. Mgt." to use? can you guys help me find out? Also, the above way is working fine.. what should I do?

I have the same question (0)
  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at

    Hi 

    code is right. Add 

    CreateItem."No" := From No. series. I think this missing in your code. This is primary key and it is mandatory for creating Item

    Regards

    Amit Sharma

  • Verified answer
    YUN ZHU Profile Picture
    95,681 Super User 2025 Season 2 on at

    Hi, I think you can insert an Item with only No. first, and then run Apply Template. If you don't want any action on the UI, you can look into the following code.

    pastedimage1663721042049v1.png

    pastedimage1663721054351v2.png

    pastedimage1663721096664v3.png

    pastedimage1663721123126v4.png

    pastedimage1663721165551v5.png

    Hope this helps.

    Thanks.

    ZHU

  • Govinda Kumar Profile Picture
    2,304 Moderator on at

    Dear YUN ZHU

    Thank you

    First inserting the item record, with No. and Description, and then applying the template with the ApplyItemTemplate procedure is working great.. this is what I was looking for.. thanks for helping.

    Regards.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,606

#2
YUN ZHU Profile Picture

YUN ZHU 931 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans