# Using custom field types

**URL:** <https://forum.litium.com/t/using-custom-field-types/1125>\
**Category:** Questions\
**Created:** [September 26, 2019, 3:03pm UTC](https://forum.litium.com/t/using-custom-field-types/1125 "2019-09-26T15:03:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![saturnia](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@saturnia](https://forum.litium.com/u/saturnia)\
**Post date:** [September 26, 2019, 3:03pm UTC](https://forum.litium.com/t/using-custom-field-types/1125/1 "2019-09-26T15:03:43Z")

</div>

Good afternoon. I was wondering. I am in need of creating a custom field type. Even following the tutorial it shows all the way up to building the new field. It seems to be working fine but I do not really know how to use it after that. Not in code and I cant seem to find it anywhere in the back office.

I can from any c# class do the following:  
var test = new FieldTypes.CustomTextFieldTypeMetadata();  
However attaching it to a template is another matter. I realise I am missing something here. Any ideas?

Litium version: 7.2.3

---

<div class="post-metadata">

**Author:** ![NilsN](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/nilsn/32/302_2.png) [@NilsN](https://forum.litium.com/u/NilsN)\
**Post date:** [September 27, 2019, 6:54am UTC](https://forum.litium.com/t/using-custom-field-types/1125/2 "2019-09-27T06:54:07Z")

</div>

You need to create a field definition using your custom field type, then you can add it to a template. If you go to the Settings \> the module you want to use the field in \> Fields, you can create the field by clicking New and selecting your custom field type in the list. Then you can go to Field Templates, edit a template and add the newly created field.

Programmatically, you create the field with something like (inject the services in the constructor):

```auto
var field = new FieldDefinition<ProductArea>("MyField", "CustomFieldTypeName")
{
	CanBeGridColumn = false,
	CanBeGridFilter = false,
	MultiCulture = false,
};

using (_securityContextService.ActAsSystem())
{
	_fieldDefinitionService.Create(field);
}

```

Then it depends on if you want to create a new template or add it to an existing one. In the Accelerator you can check out Definitions for some more examples.

---

<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:** [September 27, 2019, 1:31pm UTC](https://forum.litium.com/t/using-custom-field-types/1125/3 "2019-09-27T13:31:33Z")

</div>

You can also look att

> ProductsDefinitionSetup.cs

to see how the initial setup is created.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [October 25, 2019, 1:31pm UTC](https://forum.litium.com/t/using-custom-field-types/1125/4 "2019-10-25T13:31:38Z")

</div>

Closed on October 25, 2019, 1:31pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
