Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

How to use Item template by default when creating new item

Posted on by Microsoft Employee

I have imported the data through xml port into a table and now iam  creating new items out of it , when i create new items how can i use the item template based on my selection of which template to use.

 is there any event subscriber for that, any help will be great, Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use Item template by default when creating new item

    Thank you it helped

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,748 Super User 2024 Season 1 on at
    RE: How to use Item template by default when creating new item

    Maybe you could try to apply the template after the item is inserted?

    So switch the two lines before your end statement.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use Item template by default when creating new item

     yes Iam trying with same logic, Thanks for the heads up but can we  use this at the same time of item creation, without manually selection 'Apply Template.

     SMBItemStagingL.SetRange("Import No", ImportNoG);
            if SMBItemStagingL.FindSet() then
                repeat
                    if SMBImportSetup."SMB Template No." = '' then begin
                        Message('SMBtemplate number blank %1', SMBImportSetup."SMB Template No.");
                        ItemR.Init();
                        ItemR.Validate("No.", SMBItemStagingL.Reference);
                        ItemR.Validate("SMB Import No", ImportNoG);
                        ItemR.Validate(Description, SMBItemStagingL.Designation);
                        ItemR."SMB Import No" := ImportNoG;
                        SMBItemStagingL." Error Message" := GetLastErrorText();
                        ItemTempl.ApplyItemTemplate(ItemR, ItemTemplTableL);
                        ItemR.Insert(true);
                    end

    Any idea where I went wrong. It doesnot pick the template it creates a item without using the template

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use Item template by default when creating new item

    Thanks for the Replies, Here my plan is setup a page and the user can select a template from that at the time of item creation through a function, this function will create 100 items at a time for every 100 item a template can be selected, if there is no template is selected then it will only create item with no template

  • Suggested answer
    Manan_Shah Profile Picture
    Manan_Shah 1,457 on at
    RE: How to use Item template by default when creating new item

    Hi Sainudheen,

    With customization you can fulfil your requirement, But it's little confusing like if you are using multiple config. Template for Item creation then 1 of them you want to use as default. Then what is the use of multiple template creation and purpose of selecting template while create a new Item. Because as choose default template system will apply default template on each new Item creation. So I suggest either use only 1 template. Else as I mention you have to do customization. 

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 73,696 Super User 2024 Season 2 on at
    RE: How to use Item template by default when creating new item

    Hi, Sorry I didn't test it in detail. You can change your mind. After the Item is inserted, you can execute the following method.

    codeunit 1336 "Item Templ. Mgt."

    pastedimage1674780911563v2.png

    This is similar to running Apply Template after creating an item on the BC UI.

    pastedimage1674780998565v3.png

    Hope this helps.

    Thanks.

    ZHU

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use Item template by default when creating new item

    I have setup page and I can select which one I need and based on the selection item will be created using the template

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: How to use Item template by default when creating new item

    Do you want to use one or both? If one then delete the other one and it will automatically apply.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use Item template by default when creating new item

    I need use of the template above

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: How to use Item template by default when creating new item

    Do you mean you have to create template like above? or use one of the templates from those?

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans