Item template configuration

souoik
Member Posts: 128
Hello
for importing list from excel (create item and update existing item) how can apply item configuration template for new item in c/al ou al
Thank you
for importing list from excel (create item and update existing item) how can apply item configuration template for new item in c/al ou al
Thank you
0
Best Answer
-
Not a problem.
You can have one template code at a time to create an Item. You have to know which one to use. Maybe store this code in your table, for example, in a field ConfigurationTemplateCode
Then your code will be something like this :
if mytable.findset then
repeat
ConfigurationHeader.RESET;
ConfigurationHeader.SETRANGE(Code,mytable.ConfigurationTemplateCode);
ConfigurationHeader.FINDFIRST;
ItemTemplate.InsertItemFromTemplate(ConfigurationHeader,Item);
until mytable.next = 0;United Kingdom1
Answers
-
you can specify configuration template as part of configuration package (Rapid start) import.United Kingdom0
-
@Developer101 non i need to use when validate create new item , i create à table whosh à storage my importer item liste0
-
What version of NAV you are using? There are some standard functions you could use to create an item using a configuration templateUnited Kingdom0
-
@Developer101 Business central latest version on al code0
-
You could do something like this
ItemTemplate: Record "Item Template";
Item: Record Item;
ConfigurationHeader: Record "Config. Template Header";
ConfigurationHeader.RESET;
ConfigurationHeader.SETRANGE(Code,'ITEM000001');
ConfigurationHeader.FINDFIRST;
ItemTemplate.InsertItemFromTemplate(ConfigurationHeader,Item);United Kingdom0 -
But if i have authore configuration code not 1 , and where i can insert this code before item.insert or after0
-
Sorry I didn’t understand your question. Please could you type it more clearlyUnited Kingdom0
-
@Developer101 ok firstly thank you, seconde you can have 1 or 2 template code ok how can set whish one use ok, and am currently to validate lines from my spécifications table whish am importer from excel so i have à validate function for insert into item database rhe Last line is item.insert so where can add your code before insert or after or before
if mytable.findset then
Repeat
Item.insert
Until mutable.next =0;0 -
Not a problem.
You can have one template code at a time to create an Item. You have to know which one to use. Maybe store this code in your table, for example, in a field ConfigurationTemplateCode
Then your code will be something like this :
if mytable.findset then
repeat
ConfigurationHeader.RESET;
ConfigurationHeader.SETRANGE(Code,mytable.ConfigurationTemplateCode);
ConfigurationHeader.FINDFIRST;
ItemTemplate.InsertItemFromTemplate(ConfigurationHeader,Item);
until mytable.next = 0;United Kingdom1 -
@Developer101 in "Item Template"; haven't InsertItemFromTemplate in business central cloud juste one global funtcion CopyFromTemplate , and setrange ConfigurationHeader.SETRANGE(Code,mytable.ConfigurationTemplateCode); i haven't to code template in my table so i need to insert automatically first code0
-
Sorry check Codeunit "Item Templ. Mgt." instead of Item Template.United Kingdom0
-
Yes on this codeunit i see function applytemplateitem so how can be called this function on after item.insert on my code
Thank you for sharing0 -
can be used in similar way. Have you checked the function CreateItemFromTemplate of this codeunit and its parameters?United Kingdom0
-
I shared whit you thé function onthis code unit ok , and my parte of insert line into item table for create new item0
-
Ok great hopefully all good nowUnited Kingdom0
-
@Developer101 this my code
// Update or Insert Categorie
ConfigurationHeader.SetRange("Table ID", 27);
ConfigurationHeader.SetRange(Code,ItemRecBuffer.ModelItem);
if ItemTemplat.FindSet() then begin
ItemTemplMgt.UpdateItemFromTemplate(ItemRec);
Itempage.EnableControls();
Itempage.Update();
end;
// Update or Insert Categorie
//first check Parent
ItemRec.Insert(true);
ItemTemplMgt:codeunit codeunit 1336 "Item Templ. Mgt."
i use this function
UpdateItemFromTemplate
procedure UpdateItemFromTemplate(var Item: Record Item)
var
IsHandled: Boolean;
begin
IsHandled := false;
OnUpdateItemFromTemplate(Item, IsHandled);
if IsHandled then
exit;
UpdateFromTemplate(Item, IsHandled);
end;
local procedure UpdateFromTemplate(var Item: Record Item; var IsHandled: Boolean)
var
ItemTempl: Record "Item Templ.";
begin
IsHandled := false;
OnBeforeUpdateFromTemplate(Item, IsHandled);
if IsHandled then
exit;
if not CanBeUpdatedFromTemplate(ItemTempl, IsHandled) then
exit;
ApplyItemTemplate(Item, ItemTempl, GetUpdateExistingValuesParam());
end;
///
author function in this codeunit .
procedure ApplyItemTemplate(var Item: Record Item; ItemTempl: Record "Item Templ."; UpdateExistingValues: Boolean)
begin
ApplyTemplate(Item, ItemTempl, UpdateExistingValues);
InsertDimensions(Item."No.", ItemTempl.Code, Database::Item, Database::"Item Templ.");
OnApplyItemTemplateOnBeforeItemGet(Item, ItemTempl, UpdateExistingValues);
Item.Get(Item."No.");
end;
plase if you can give the correct syntax ti use this codeunit for applying item template0 -
CreateItemFromTemplate is the function I would use to create an item from a template . I am just helping you to see which function you could use (refer to your original query). The rest you will know better what you are trying to achieve. May be message me on private and we go through it.United Kingdom0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions