'(Declarations) ' Available Objects: ' BaseObjectEngine - PCS Base Object Engine ' LookupObjectEngine - PCS Lookup Table Engine ' WorkflowData - PCS Workflow Data Engine ' MetaObjectEngine - PCS Def Object Engine ' DB - PCS Database Engine ' DataItem - PCS Workflow DataItem ' ScriptInfoObject - PCS Workflow Script Parameter Collection ' 'End of (Declarations) Dim FSO Dim TSO ' TabStop = Chr(9) ' NewLine = Chr(10) Const ForWriting = 2 Const ForReading = 1 Const ForAppending = 8 Const TristateFalse = 0 Public Function WorkflowScript() '============================================================== ' On Error Resume Next is the only form of error handling in ' VBScript. If an error is raised out of a script while it ' is running, it may cause the workflow system to slow. ' Therefore, please use On Error Resume Next in conjunction ' with the Err Object to handle any errors ' that may occur. '============================================================== On Error Resume Next Dim DataItem Dim File1 Dim File2 Dim OutFile Dim xmlString Dim xslString Set FSO = CreateObject("Scripting.FileSystemObject") 'Get the final location of the file Set DataItem = WorkflowData.GetItemEx("[FilePointer]") OutFile = DataItem.Value Set DataItem = Nothing 'the value we want to use as a temporary location File1 = FSO.GetTempName 'The Stylesheet as a parameter File2 = ScriptInfoObject("[StyleSheet]").ParameterValue 'Export the Account to a file ExportAccount File1 'Read in the source file--See the Wkflw_Files example script for the Readfile function xmlString = ReadFile(File1) 'Read in the Stylesheet xslString = ReadFile(File2) TransformXMLAndSave xmlString, xslString, OutFile FSO.DeleteFile sfile1 '=============================================== ' The following values are valid return codes '----------------------------------------------- ' 0 = Success - (Default) ' -1 = Failure - Mark task as failed ' -2 = Failure - Mark task as failed and Raise WithException Flag ' -3 = Failure - Mark task as failed and Rollback workflow '=============================================== WorkflowScript = 0 '(Default) Success End Function Public Function TransformXMLAndSave(ByVal sXML, ByVal sXSL, ByVal sFile) Dim xmlDoc Dim xslDoc Dim sData Set xmlDoc = CreateObject("MSXML2.DOMDocument") Set xslDoc = CreateObject("MSXML2.DOMDocument") 'Open the Text file for writing Set TSO = FSO.OpenTextFile(sFile, ForWriting, True, TristateFalse) 'Load the XML and XSL Documents xmlDoc.loadXML sXML xslDoc.loadXML sXSL 'Transform the XML based on the XSL and save to a string sData = xmlDoc.transformNode(xslDoc) 'Write to the file TSO.WriteLine sData TSO.Close End Function Public Function TransformXMLAndPost(ByVal sXML, ByVal sXSL, ByVal sURL) Dim xmlDoc Dim xslDoc Dim oXMLHTTP Dim sData Set oXMLHTTP = CreateObject("MSXML.XMLHTTP") Set xmlDoc = CreateObject("MSXML2.DOMDocument") Set xslDoc = CreateObject("MSXML2.DOMDocument") 'Load the XML and XSL Documents xmlDoc.loadXML sXML xslDoc.loadXML sXSL 'Transform the XML based on the XSL and save to a string sData = xmlDoc.transformNode(xslDoc) 'Open the URL oXMLHTTP.open "POST", sURL, False 'Post the transformed XML to the URL oXMLHTTP.send (sData) End Function Public Function TransformXMLFileAndSave(ByVal XMLFile, ByVal XSLFile, ByVal sFile) Dim xmlDoc Dim xslDoc Dim sData Set xmlDoc = CreateObject("MSXML2.DOMDocument") Set xslDoc = CreateObject("MSXML2.DOMDocument") 'Open the Text file for writing Set TSO = FSO.OpenTextFile(sFile, ForWriting, True, TristateFalse) 'Load the XML and XSL Documents from files xmlDoc.Load XMLFile xslDoc.Load XSLFile 'Transform the XML based on the XSL and save to a string sData = xmlDoc.transformNode(xslDoc) 'Write to the file TSO.WriteLine sData TSO.Close End Function