7

I am working with Web 8 on SDL Cloud and DXA 1.4.

I have created a C# TBB and using it in a Component Template associated with a multimedia Component. This TBB inserts/updates a value in multimedia Component metadata and saves the Component as well.

The behavior that I am getting, is that while I try to Preview in CME or run through Template Builder, the metadata of the Component got updated; however, if I try to publish the Component, the metadata value of the Component does not update in CME.

I verified that publishing is happening successfully with the relevant Template.

NOTE: I know the associated issues with adding custom meta dynamically while publishing to broker - I am here mentioning the issue related to a metadata field update in the Component in CMS.

1
  • Note that it is recommended against updating components in Template code ... you should consider if some sort of extension would be more appropriate (and therefore visible / manageable) Nov 10, 2016 at 9:38

4 Answers 4

9

As mentioned for TBBs to be able to make changes to CM items, you need to set allowWriteOperationsInTemplates = true in the Tridion.ContentManager.config on all machines that are rendering for you, so this means all CM servers and all Publisher servers.

Please note that as documented, SDL strongly recommends against this practice as it compromises your security. So I would be quite surprised that this would actually be allowed in SDL Cloud.

As a solution I would suggest to move this code from the TBB into an event handler, that is a more secure way of doing these type of actions. See also my discussion around this topic in relation to ECL event handlers http://www.tridiondeveloper.com/ecl-event-handlers, it covers a similar topic.

1
  • Looks like the SDL Cloud team has seen this post and sent the same information to me - now all makes sense and implementing through Event System is the way to go - Thanks Bart Nov 11, 2016 at 8:53
4

Templates are read-only unless you change the CM configuration. Do you have a separate publisher? Have you changed the configuration on that system?

Just noticed the "Cloud" part - As Bart mentions, I'm not sure that changing the configuration is supported in that case. For on-premise the relevant documentation under Backwards compatibility and API changes in Content Manager (search for allowWriteOperationsInTemplates)

7
  • 1
    I'm wondering if template write features are even enabled at all on SDL Cloud, sounds like a security issue which they won't allow. Nov 10, 2016 at 9:20
  • Indeed, I thought it strange that it worked for preview. Perhaps that by-passes the check? Nov 10, 2016 at 9:22
  • Preview works with the rights of the current user, but indeed I find it strange it does work there indeed, unless they have changed the allowWriteOperationsInTemplates option on the CMS Nov 10, 2016 at 9:24
  • Thanks guys - allowWriteOperationsInTemplates = true in the Tridion.ContentManager.config Nov 10, 2016 at 9:26
  • 1
    @PankajGaur in that case I think it is not set equal on the Publisher server Nov 10, 2016 at 9:27
3

I'd suggest to check if publishing service user has rights to update the Component on that particular Publication.

Can you update the question with the logs, if there is any error?

1
  • Thanks Saurabh. I just updates the log in TBB and indeed this seems some issue - While publishing, it gives some permission access related error while no such error comes while preview - let me further dig this and suggestion made by @Bart Nov 10, 2016 at 9:32
3

There's a configuration setting that, by default, sets templates to have read-only access to the TOM.NET API.

See allowWriteOperationsInTemplates (and set to true) in the tridion.contentmanager.security element in the Tridion.ContentManager.config

As noted in other posts here - this deprecated approach is strongly recommended against.

2
  • 2
    while the setting happens to be the same, you should not refer to the 2013 documentation, when the OP mentions he is using Web 8 (which technically also isn't true, since they are using SDL Cloud, which is versionless basically as it is updated and maintained by SDL Cloud ops docs.sdl.com/LiveContent/content/en-US/SDL%20Web%20Cloud-v1) Nov 10, 2016 at 9:42
  • Thanks Bart - missed that (despite it being mentoned in the opening sentence and as a tag!!! Also - I see I posted this just after yours too! Nov 10, 2016 at 10:04

Your Answer

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

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