Sarkis Einarsson
Sarkis Einarsson

Reputation: 31

Glass Mapper, TDS Code Generation and Rich Text field in Sitecore

Using Glass.Mapper version 3.0.13.25. Using TDS 5.0.0.23 Code Generation (glassv3header.tt and glassv3item.tt).

I have a new Item that I am trying to add to Sitecore. I'm populating a Product object that was created through TDS' Code Generation...

Product createdProduct = service.Create(DestinationFolder, newProduct);

I'm getting the following error when I try to run my code...

It is not possible to save data from a rich text field when the data isn't raw.Set the SitecoreFieldAttribute setting property to SitecoreFieldSettings.RichTextRaw for property Full_Description on type Mizuno.Data.Domain.Product

Looking at the Glass Mapper code, it looks like I have to set some config.Setting to SitecoreFieldSettings.RichTextRaw, but I'm not sure what/where/how I do this using the code generated by TDS...

Any insight on this would be helpful.

-Sarkis-

Upvotes: 3

Views: 2108

Answers (2)

devMd
devMd

Reputation: 49

Hey it's a bit late but i have found a solution for this. So first you have to disable the code generation for that item. Go to TDS project right click, then Properties. There's a field called "Code Generation Template" set that in None, and in you class put this as a property:

[SitecoreField("FieldName", Setting = SitecoreFieldSettings.RichTextRaw)]
public virtual string FieldName { get; set; }

Hope it helps

Upvotes: 1

Michael Edwards
Michael Edwards

Reputation: 6528

I don't think this is possible with TDS unless you alter the standard TT template and then use Custom Data in TDS. This might be a lot of work.

You might be better sub-classing the original model and then adding a different attribute, I haven't tested this but it should work:

public class ProductWrite : Mizuno.Data.Domain.Product {

    [SitecoreField(Settings = SitecoreFieldSettings.RichTextRaw)]
    public override string Full_Description { get; set; }

} 

Let me know if this works.

Upvotes: 1

Related Questions