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 am populating a product object that was created via TDS code generation ...

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

      

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

It is not possible to store data from a rich text box when the data is not raw. Set the SitecoreFieldAttribute setting property to SitecoreFieldSettings.RichTextRaw for the Full_Description property of type Mizuno.Data.Domain.Product

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

Any understanding of this would be helpful.

-Sarkis -

+3


source to share


2 answers


I don't think it is possible with TDS unless you change the standard TT template and then use custom data in TDS. This can be a lot of work.

You might be better off subclassing the original model and then adding another 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.

+1


source


Hey this is a little late but I found a solution for this. So first you need to disable code generation for this item. Right click on the TDS project, then select Properties. There's a field called "Code Generation Template" set to None, and in your class put this as a property:

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

      



Hope it helps

+1


source







All Articles