Hi,
Is there a way of saving an Html document to which Mail Merge tags were added in order to run the mail merge at another time or using another tool?
For example, when creating/editing a Word document using RadRichText, I can add Mail Merge tags (fields) to the document and save that document without clicking the Mail Merge (Finish) button. This way may (mail merge) tags are saved so that when re-opening the document, I can continue adding mail merge items or complete the mail merge at that point (or even link it to a different dataset).
When I create/open and HTML document and try to export as Html (or even save as an Html document) after adding tags, I receive the following error:
This inline is not supported: FieldRangeStart
My end goal is to be able to export the html document (with tags) in order to store it in the database and import again later to modify and finally merge the data.
Thank you
9 Answers, 1 is accepted
@Joe There is a known bug with importing merge fields from docx in 2011 Q2, if you are using it you should upgrade to Q2 SP1 in order to use this functionality.
@Attention: Norm: As merge fields are not supported by HTML, our HtmlFormatProvider don't export them. You can instead use XamlFormatProvider or DocxFormatProvider (and XAML or docx as intermediate format), which support importing/exporting merge fields.
Kind regards,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Because of this I cannot have a "template" document that can be later imported so as to merge with other data.
I tried to manually put a DOCX file together with the merge field place-holders using Microsoft Word, but those fields are just imported as plain text and will not map to the data.
Any suggestions?
I modified my logic to try and replace the mail merge tags with different tags using search and replace.
This seems to change the Telerik Mail Merge tags (ie. { MERGEFIELD FieldName } ) but it appears that when Mail Merge fields are added to the document that there are some hidden tags which still prevent saving using the HtmlFormatProvider.
When instead I highlight the mail merge tag and delete it and then try to save using the HtmlFormatProvider, it works fine.
How can I add in the merge fields so that I am able to preview the document by selecting Preview Results, then in order to save showing all field codes again (which I have coded already), and then replace the Telerik Mail Merge field tags with my own so that the HtmlFormatProvider doesn't have issues?
Thanks
NOTE: I have opened a support ticket for this...
@Joe: Actually the merge fields are exported to docx format, but they preserve a value from the previous data source. If you update them in any way, you will see the values from the new data source, for example:
// set your data source here
this
.radRichTextBox.Document.MailMergeDataSource.ItemsSource =
new
List<Person>()
{
new
Person()
{
FirstName =
"Aaaa"
,
JobTitle =
"Bbb"
}
};
// change fields display mode
this
.radRichTextBox.ChangeAllFieldsDisplayMode(FieldDisplayMode.Result);
@Attention: Norm:
We answered you in the support ticket you opened.
All the best,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Mail merge fields are preserved in docx export-import round-trip, but they preserve a value from the data source in their presentation (please refer to the solution in my previous post for this).
If you continue to experience problems, please send us a sample document (exported to XAML), which fails to export its merge fields to docx.
Greetings,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I'm exporting my merge fields as Xaml, and its importing exporting correctly.
However, i'm also using Custom Fields which i use to bring in dynamic sets of data. And it seems to export correctly, however when i import i get the following crash:
Crash when loading Custom Merge Field into RadDocument from XAML
The tag 'CustomMergeField' does not exist in XML namespace 'clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents'. Line '18' Position '10'.
at System.Windows.Markup.XamlParser.ThrowExceptionWithLine(String message, Int32 lineNumber, Int32 linePosition)
at System.Windows.Markup.XamlParser.ThrowException(String id, String value1, String value2, Int32 lineNumber, Int32 linePosition)
at System.Windows.Markup.XamlParser.WriteUnknownTagStart(XamlUnknownTagStartNode xamlUnknownTagStartNode)
at System.Windows.Markup.XamlParser.ProcessXamlNode(XamlNode xamlNode, Boolean& cleanup, Boolean& done)
at System.Windows.Markup.XamlParser.ReadXaml(Boolean singleRecordMode)
at System.Windows.Markup.TreeBuilderXamlTranslator._Parse()
at System.Windows.Markup.XamlParser.Parse()
at System.Windows.Markup.XamlTreeBuilder.ParseFragment()
at System.Windows.Markup.TreeBuilder.Parse()
at System.Windows.Markup.XamlReader.XmlTreeBuildDefault(ParserContext pc, XmlReader reader, Boolean wrapWithMarkupCompatReader, XamlParseMode parseMode, Boolean etwTracingEnabled)
at System.Windows.Markup.XamlReader.Load(XmlReader reader)
at System.Windows.Markup.XamlReader.Parse(String xamlText)
at Telerik.Windows.Documents.FormatProviders.Xaml.XamlFormatProvider.Import(String input) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Documents\Telerik.Windows.Documents.FormatProviders.Xaml\XamlFormatProvider.cs:line 126
I gather that this is just not supported, but is there any other way to do this? I've got the custom fields working great, i'd just like to be able to import documents with these in there.
The only thing i can think of is having my own process to add it back in manually, but that is really messy.
Cheers,
Steve
Since 2011 Q3 SP1, we support importing and exporting custom document elements, so your scenario will be supported without extra effort. However, if upgrading is not an option for you, I can suggest a workaround: before export, you replace all your custom fields with bookmarks, serializing your field info in the bookmark name, and recreating the fields upon import.
Let us know if you need additional assistance.
Greetings,
Ivailo Karamanolev
the Telerik team