The Mobile Impact Platform allows for customizing your exports according to your needs, such as integrating with 3rd party systems or exporting to other file format types. The standard export types available are PDF, CSV, XML and SQL. Use this guide for information on correctly running custom exports. 


The main structure of custom exports looks like this:

  1. Check to see if you've exported before successfully
  2. Try to do the export
  3. Record whether the export is successful


Here is an example custom export:


Const CUSTOM_EXPORT As String = "Custom Export Name"    ' The Custom Export ID

    ' Use to add custom data path exports
    <MiCode(FormScriptEventType.AfterDataPathsRun)> _
    Public Sub Form_AfterDataPathsRun(ByVal e As AfterDataPathsRunEventArgs)
            
        ' Step 1: Check to see if you've exported before successfully
        For Each export As ExportResult In _form.Validator.ExportResults
            If export.ID = CUSTOM_EXPORT And export.Success Then
                ' Yes, we have exported successfully so exit
                Return
            End If
        Next

        ' Step 2: Try to do the export
        Dim success As Boolean = False
        Try
            Dim customFileName As String = GetCustomFileName()  ' Constructs the filename
            success = PerformExport(customFileName)  ' The actual export occurs here

            ' Step 3: Record whether the export is successful... 
            If success Then
                
                ' ... the export was successful
                RecordExportResult(CUSTOM_EXPORT,
                                True,
                                "",
                                "",
                                "",
                                customFileName)    ' Success
            Else

                ' ... the export was not successful
                RecordExportResult(CUSTOM_EXPORT,
                                False,
                                "Export failed",
                                "Export failed",
                                "Export failed")    ' Fail

            End If
        Catch ex As Exception
            RecordExportResult(CUSTOM_EXPORT,
                            False,
                            ex.Message,
                            ex.Message,
                            ex.Message)    ' Fail with an exception message
            success = false
        End Try

        If Not success Then
            e.CustomExportDetails = CUSTOM_EXPORT & " unsuccessful."
            e.CustomExportFailure = True
        End If
    End Sub


In Step 1, the collection of export results (_form.Validator.ExportResults) is checked for our custom export. Once found, if the export result was successful then the function is exited since the custom export has already been accomplished. Please note that if your form contains more than 1 custom export, all export results should be checked for success before exiting the function. 


In Step 2, the custom export is attempted. Please note the use a Try, Catch, End Try exception handler in case there's an exception raised by any of the surrounding code. In the example, the intended custom file name is generated first (GetCustomFileName) and then used as a parameter to the function that will perform the actual export (PerformExport). 


In Step 3, depending upon the success of the export (boolean "success"), different parameters are sent to RecordExportResult. Note on success that the intended custom file (customFileName) is sent as the last parameter. Note that the RecordExportResult is used for the Fail case and also if an exception is raised during the export.


In the above custom export example, please note the following:

  • The CUSTOM_EXPORT string constant- the custom export id. Having a consistent export id to refer to the same export is important so the Server can track the status of each export for the session. If there are multiple custom exports, define a unique string constant for each.


  • The AfterDatapathsRun event handler. After all standard datapath exports have been completed, the Server will execute the code within the AfterDatapathsRun event handler. Please note the following important arguments ("e" As  AfterDataPathsRunEventArgs) are set :
    • CustomExportFailure - Boolean. Indicate whether the custom export(s) failed or succeeded.
    • CustomExportDetails - String. Describe details on the custom export failure.