Changes to Email Body of Orchard Rule not persisting when total approaches 4000 chars

Topics: Administration, Core, General
Mar 7, 2013 at 11:06 PM
I have a verbose email message that is being triggered via a Rule in orchard but when ever I try to save my changes they are not persisted, however only if my body is over a certain length. I took a look at the database field behind the rule action and found that dbo.Orchard_Rules_ActionRecord.Parameters column is of type nvarchar(MAX) so that's not the issue as far as I can tell. Does anyone know why Orchard would prevent saving of an email action if the body of the email is large? It looks like it serializes the entire email action to the Parameters column and it's pretty damn close to 4000 characters to be a coincidence.

I'm not familiar enough with the innards of Orchard's data model so I was wondering if someone could help me track down why it appears to prevent changes when the length of what would go into Parameters column is large?
Mar 8, 2013 at 1:58 AM
Can you please file a bug with repro steps?
Mar 11, 2013 at 4:31 PM
I was able to reproduce the problem in a clean install of Orchard, and I've created an issue here. Any word of a work around would be greatly appreciated
Mar 11, 2013 at 4:35 PM
Thanks. The only workaround I can see for now is to keep it short.
Mar 17, 2013 at 7:30 AM
Hi to all,
I have the same problem with a string field in another module. If the length exceed 4000 chars I got a persistence error even if the field is marked as unlimited in migrations. I also tried a workaround using alteration
public class MappingAlteration : IAutoMappingOverride<ChartRecord>
        public void Override(AutoMapping<ChartRecord> mapping)
            mapping.Map(f => f.ChartDefinition).CustomSqlType("nvarchar(max)");
but without success, any help?
Mar 18, 2013 at 4:53 PM
I just fixed it in changeset cecf1183e2fa

You can apply the patch locally.
Mar 19, 2013 at 5:58 PM
Awesome, thanks a lot Sabastien.

For anyone else looking to use this update, I was able to make the same changes Sabastien has in this fix to the two files in Modules\Orchard.Rules\Models folder, then delete the App_Data\Dependencies folder. Next time I hit the site the modules were rebuilt and the problem was gone.