# Create new fieldTemplate from code

**URL:** <https://forum.litium.com/t/create-new-fieldtemplate-from-code/426>\
**Category:** Questions\
**Created:** [December 12, 2018, 10:13am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426 "2018-12-12T10:13:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![emilsjog](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@emilsjog](https://forum.litium.com/u/emilsjog)\
**Post date:** [December 12, 2018, 10:13am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/1 "2018-12-12T10:13:03Z")

</div>

I have created a fieldtemplate from code and I can see it in the database and it looks like the other templates that are there. But it is not displayed in the list of templates in the BO. Am I missing something important that is needed for the template to show?

Litium version: 7

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 12, 2018, 10:16am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/2 "2018-12-12T10:16:25Z")

</div>

Restart your website and try.

---

<div class="post-metadata">

**Author:** ![emilsjog](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@emilsjog](https://forum.litium.com/u/emilsjog)\
**Post date:** [December 12, 2018, 10:26am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/3 "2018-12-12T10:26:05Z")

</div>

Ok, It worked. But Is that the only way to make the template visible in the BO?

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 12, 2018, 10:29am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/4 "2018-12-12T10:29:10Z")

</div>

I am not sure if there are other ways to do this, if so someone else will reply on this thread.

---

<div class="post-metadata">

**Author:** ![emilsjog](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@emilsjog](https://forum.litium.com/u/emilsjog)\
**Post date:** [December 12, 2018, 1:20pm UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/5 "2018-12-12T13:20:55Z")

</div>

Ok, I hope that someone else can reply then

---

<div class="post-metadata">

**Author:** ![ton.nguyen](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ton.nguyen/32/989_2.png) [@ton.nguyen](https://forum.litium.com/u/ton.nguyen)\
**Post date:** [December 12, 2018, 2:07pm UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/6 "2018-12-12T14:07:11Z")

</div>

Do you mind sharing how you create the template from Code, and when, in what phrase do you have that code? The cache should be purged when new template is created.

---

<div class="post-metadata">

**Author:** ![emilsjog](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@emilsjog](https://forum.litium.com/u/emilsjog)\
**Post date:** [December 12, 2018, 2:10pm UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/7 "2018-12-12T14:10:02Z")

</div>

I have created it as simple as possible so far.

```auto
        _fieldTemplateService.Create(new ProductFieldTemplate(id, "Product")
                {
                    ProductFieldGroups = new[]
                        {
                            new FieldTemplateFieldGroup
                            {
                                Id = "General",
                                Collapsed = false,
                                Localizations =
                                {
                                    ["sv-SE"] = { Name = "Allmänt" },
                                    ["en-US"] = { Name = "General" }
                                },
                                Fields =
                                {
                                    "_name"
                                }
                            }
                        },
                    VariantFieldGroups = new[]
                        {
                            new FieldTemplateFieldGroup
                            {
                                Id = "General",
                                Collapsed = false,
                                Localizations =
                                {
                                    ["sv-SE"] = { Name = "Allmänt" },
                                    ["en-US"] = { Name = "General" }
                                },
                            },
                        }
                });
```

---

<div class="post-metadata">

**Author:** ![ton.nguyen](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ton.nguyen/32/989_2.png) [@ton.nguyen](https://forum.litium.com/u/ton.nguyen)\
**Post date:** [December 12, 2018, 8:16pm UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/8 "2018-12-12T20:16:13Z")

</div>

When do you create it? During the time when the website is starting or after it has been started?

---

<div class="post-metadata">

**Author:** ![emilsjog](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@emilsjog](https://forum.litium.com/u/emilsjog)\
**Post date:** [December 13, 2018, 8:46am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/9 "2018-12-13T08:46:28Z")

</div>

It is created **after** the site has been started because it is triggered by an integration

---

<div class="post-metadata">

**Author:** ![ton.nguyen](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/ton.nguyen/32/989_2.png) [@ton.nguyen](https://forum.litium.com/u/ton.nguyen)\
**Post date:** [December 14, 2018, 10:13am UTC](https://forum.litium.com/t/create-new-fieldtemplate-from-code/426/10 "2018-12-14T10:13:45Z")

</div>

Ok, sounds like a bug. Please file a bug with concrete steps to reproduce.
