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

2k views Asked by At

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-

2

There are 2 answers

0
devMd On

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

0
Michael Edwards On

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.