I was wondering if it is possible to assign or change the value of a Component Field during templating? Is there any way to accomplish this?

Say for eg :

List<ItemFields> fieldslist = (List<ItemFields>)comp.EmbeddedValues("attributes");
foreach (ItemFields fields in fieldslist) {
    fields.StringValue("someAttribute") = mycustomvalue_as_per_scenario;
  • Welcome to the Tridion Community! May I suggest that it is recommended to demonstrate research you have done/what you've tried before asking. If you do so, folks here will be more receptive to provide a good answer. Cheers. Commented Nov 6, 2013 at 6:16
  • Its a strange requirement - Don't forget that templates are also executed with preview, XPM session preview and in the template builder, so any updates you do are not limited to publish time - what exactly are you trying to achieve?
    – Will Price
    Commented Nov 6, 2013 at 13:51

2 Answers 2


In addition to Nick's technical answer, I want to add the philosophical angle -- Why would you want to modify a field during template execution? While technically this is possible, it makes no sense to do so while the template is executing.

I understand you want to change a field value, then save the Component to propagate your change to the CM database. This is a valid use-case... just not while templating. The template itself is a text (sometimes binary) transformation of some content. The analogy here would be someone making an XML - XSLT transformation and attempting to change the source XML while transforming. Technically possible? Sure. But it makes no sense, since that's why you are performing the transformation in the first place.

You can use event system if you want to validate some values or change them upon saving.

You can use GUI extensions or custom URLs to pull in different values or change/format values.

You can use the Core Service to change field values programmatically from some content import application.

Perhaps you can detail your use case and I'll try to come up with the right solution.


Yes, it is possible modifying fields via the TOM.NET API or Core Service inside a C# TBB.

If you use TOM.NET for this instead of Core Service, you can not do any write operations on the items being rendered/published within the same publish session. There is also a setting in Tridion config that you have to enable to allow writing from templates (I can't remember which one ATM). Best is to use Core Service for this.

  • 2
    See my blog post on tridiondeveloper.com in there I've explained how to enable write operations in Templates (attribute allowWriteOperationsInTemplates in Tridion.ContentManager.config file, as documented here, requires login). example code of a TBB performing a write operation I have avaialble on GitHub Gist. Commented Nov 6, 2013 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.