Producing export files with MDrivenServer

ServerSide Viewmodels are defined and executed periodically as described in this earlier article //

In the last section of that article I mention the ability to send emails by naming an action column to “email”.

Now you can also write files by adding an action column called “savefile”; when the periodic action supervisor in BorPred sees this action column it looks for two additonal columns; path and filename (case insensitive). If these are found the complete result of the ViewModel is streamed out as xml by using the ViewModelXMLUtils.GetDataAsXml method. The xml is then saved to path/filename.

Sort of like this:


In a real world application it looked like this:


Notice that both path and filename are evaluated expressions, further more the Action UpdateExportTime is executed last – and it changes some data. Since the whole execution is wrapped in a memory transaction we make sure that we do not update the export time unless the file was written and everything is ok.

The resulting file looked like this:



This action (SaveFile action) has been updated to look for a column named xslt, if it is found the contents of the field is assumed to be a valid xslt transformation. The xml from the viewmodel is transformed with the xslt and the result is saved as above.

So if your xslt is…

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='' version='1.0'>
<xsl:output method='text' omit-xml-declaration='yes'/>
    <xsl:template match='/Root/SalesArticles/SalesArticle'>
            <xsl:value-of select='ArticleNumber'/>,<xsl:value-of select='SalesArticleName'/>

… then your output would be…

NO101087,Cosmica Tygg 90 ST…

This entry was posted in MDrivenDesigner, MDrivenServer, ViewModel. Bookmark the permalink.

One Response to Producing export files with MDrivenServer

  1. Pingback: Import data from other SQL servers | CapableObjects

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.