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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Business Central forum

How to select item template when creating an item through code?

(0) ShareShare
ReportReport
Posted on by 450

When creating an item manually you first get prompted with a page where you can select an item template, once you selected the template the new "item card" will open and fields will be filled in according to the template. Now i've created another page with a button where i can create an item manually so all the fields are hardcoded, but i also want to make use of those templates. So what i want to have now is, if i click on the button, the templatepage will pop up. Once i've selected a template i do not want the itemcard to open but i automatically want to fill in the description.

In what way can i achieve this?

Categories:
  • Suggested answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    You have the function "NewItemFromTemplate" in the table Item Template (1301).

    By using this function you can achieve this.

    Regards

    Avinash B

  • InsertX Profile Picture
    450 on at

    I found the function that you mentioned but in what way do I use this? It takes a record of type Item as parameter but i don't see any other thing that can be modified on it..

    EDIT:

    I now found how to apply the template now the only thing i'm left wondering is how i set one more parameter on the item card without that being in the template?

  • Verified answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    You can make use of events.

    In this case, you can create a subscriber for the OnAfterInsertItemFromTemplate event from table 1301 and pass the value into item record.

    Regards

    Avinash B

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans