SaveReportData

You can use the SaveReportData function to save XML data to a file on the configured Web Reports server and return the complete file path. The file can then be passed to the FsWebReports product for report generation.

When to use

You can use this function to:

  • Save XML data to the Web Reports server for processing by the FsWebReports product.
  • Generate reports from workflow data by saving XML and passing the file to the report server.
  • Export object data as XML files to a shared location for reporting or integration.

When not to use

You cannot use this function:

  • To save files to local directories. The function saves files only to the Web Reports server location.
  • In MT SaaS implementations.

Working

  1. Web.config Configuration

    Reads Web.config option to find the Web Reports server name:

    <add key="SvcReportServerName" value="<your server>" />

  2. File Location

    Saves the XML file to this location on the configured Web Reports server:

    \\<ReportServerName>\SessionXML\<tenantID>\<XML file>

  3. File Name

    The file name is constructed using:

    • Action Set Code
    • WIP_ID (Workflow in Progress ID)
    • Timestamp
  4. Return Value

    The complete file path (\\<ReportServerName>\SessionXML\<tenantID>\<XML file>) is returned and can be passed to the FsWebReports product.

Syntax

string SaveReportData(string xml);

Parameters

Parameter Type Required Description
xml string Yes The XML string data to save to a file.

Return Value

The application returns the complete file path to the saved XML file on the Web Reports server.

Prerequisites

  • The SvcReportServerName option must be configured in Web.config.
  • The file is saved in a tenant-specific subfolder.
  • The file name is generated automatically using the Action Set code, WIP_ID, and timestamp.

Examples

Example 1
Save Report XML and Display File Path.
// Get XML data for item with all technical parameters
string res = ObjectXML("ITEM", "", "TPALL");

// Save XML to Web Reports server
string filePath = SaveReportData(res);

// Display the file path
MessageList(filePath);
Description

When you run the below Action:

  • A message is displayed with the path to the location of the generated XML file
  • The XML file is written to the Report Server
SaveReportData - Using XmlDocument.OuterXml
If you collected XML in an XmlDocument object, you can use XmlDocument.OuterXml as the string that you pass into SaveReportData.
Benefits
Benefit Description
Simpler No need to construct file path manually.
Automatic naming File name automatically generated.
Centralized Uses configured Web Reports server location.
Less error-prone No manual path construction.
Example 2
Save Report XML and Display File Path.
// Create and populate XmlDocument
XmlDocument xdTemplate = new XmlDocument();

// Generate XML (example)
string objectXml = ObjectXML("FORMULA", "FORMULA-001\\001", "HEADER;INGR");
xdTemplate.LoadXml(objectXml);

// OLD WAY - Manual file path construction
// string jobfilePath = co.FileLocation("WEBREPORTS", "XMLWORK") + "\\" + jobFileName;
// xdTemplate.Save(jobfilePath);

// NEW WAY - Use SaveReportData with OuterXml
string jobfileName = co.SaveReportData(xdTemplate.OuterXml);
MessageList($"Report file: {jobfileName}");