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?