Sample:Action for formula XML
This script is an example of creating XML for a
formula.
Function wf_launch() as long
'XML Report Script
Dim xdTemplate as New XmlDocument
Dim xfXMLFORMULA as XmlDocumentFragment
Dim xnRoot as XmlNode, xnXmlNode as XmlNode
Dim sTemplate as String, sFilePath as String, sXML as String
‘Create a template XML file to contain the report data. Include the schema names ‘to use for
the report.
sTemplate = "<fsxml><report><SchemaList><Schema>FSWB_Formula.xsd</
Schema><
/SchemaList><object /></report></fsxml>"
xdTemplate.LoadXml(sTemplate)
‘Find the XML node to insert the report data into.
xnRoot = xdTemplate.SelectSingleNode("/fsxml/report/object")
‘Create an XML file for the object. Specify details to include.
sXML = ObjectXML(_OBJECTSYMBOL, "","HEADER;INGR;TPALL;BYPROD;ST;REF;
CONTEXT;DOC;COMP;PER;STATUS;SKU")
' Strip leading and trailing <fsxml> tags before loading XML fragment
' Allows for inserting all of the FORMULA XML(s) into the template without
' having to code a for/next loop
sXML = System.Text.RegularExpressions.Regex.Replace(sXML, "(<|</
)fsxml.*?>", "")
xfXMLFORMULA = xdTemplate.CreateDocumentFragment()
xfXMLFORMULA.InnerXml = sXML
‘Insert the object data into the template XML file.
xnRoot.AppendChild(xfXMLFORMULA)
‘Save XML output to the XMLWORK path specified in the File Location form.
sFilePathXMLWork = FileLocation("WEB REPORTS", "XMLWORK")
xdTemplate.Save(Path.Combine(sFilePathXMLWork, "FSWB_Formula.xml"))
‘Combine XML data with Crystal report template, launch aspx, and display as PDF.
sFilePathSource = FileLocation("WEB REPORTS", "SOURCE")
ShellAPI("http://localhost/FsWebReports/
Launch.aspx?p1=FSWB_Formula.xml&p2=FORMULA&p3=pdf&p4=" & Path.Combine(sFilePathSource,
"FSWB_Formula_Data.rpt"))
Return 111 ‘You must include a Return code to avoid a “stuck” pending tasks'
End Function
XML output for a formula (also known as the job file) is shown here.
If you are exporting attached text for multiple objects for a report, rename the generic
FSDOC
and FSEMBEDDEDOBJECTS
tables in the <rename>
sections of the XML file to match the objects.
Attached files, documents and URLs do not need any preparation for multiple object types. The
default value is the table name with each object type, e.g., FSFORMULAATTACH
,
FSITEMATTACH
.