'(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 'Opens the file as ASCII. Const TristateTrue = -1 'Opens the file as Unicode. Const TristateUseDefault = -2 'Opens the file using the system default. 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 '=============================================== ' 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 ExportAccount(ByVal sFile) Dim XMLExport Dim xmlDoc Dim lSuccess Const NONE = 0 Const ATTRIBTYPE = 1 Const IDS = 2 Const METAPROPERTIES = 4 Const LOOKUPS = 8 Const CONTENTPROPERTIES = 16 Set XMLExport = CreateObject("PCS_XML.clsXMLExport") 'Set the options to onlyl export Content, not definitions XMLExport.ExportOptions = CONTENTPROPERTIES 'The BaseObjectEngine has already been instantiated in the Workflow 'Component that called the script, but we still need to load the group. lSuccess = BaseObjectEngine.GroupGet(WorkflowData.GroupID) BaseObjectEngine.AsOfDate = Date 'This loads the Base object and converts it to XML lSuccess = XMLExport.ParseObject(BaseObjectEngine) 'Get the XML Doc Set xmlDoc = XMLExport.DOMDocument 'Save the XML Doc to a file xmlDoc.save sFile 'OR 'Return the XML as a string to the calling routine 'ExportAccount = xmlDoc.xml End Function Public Function WriteStringToFile(ByVal sFile, ByVal sInfo) Set FSO = CreateObject("Scripting.FileSystemObject") ' Two Methods to write a string into a file ' Method 1 'Open the Text file for writing Set TSO = FSO.OpenTextFile(sFile, ForWriting, True, TristateFalse) 'Write to the file TSO.WriteLine sInfo TSO.Close ' Method 2 'Create the Text file 'Set TSO = FSO.CreateTextFile(sFile, True, False) 'Write to the file 'TSO.WriteLine sInfo 'TSO.Close End Function Public Function WriteCommaDelimFile(ByVal sFile, ByVal sObject) 'This example iterates through the WorkFlowData.AllDataItems Collection 'and writes the data to a Comma Delimited file ' Dim DataItem Dim SubCollection Set FSO = CreateObject("Scripting.FileSystemObject") Set TSO = FSO.OpenTextFile(sFile, ForWriting, True, TristateFalse) For Each SubCollection In WorkflowData.AllDataItems For Each DataItem In SubCollection TSO.Write DataItem.AttribXMLTag & "," TSO.Write DataItem.AttribName & "," TSO.Write DataItem.DataItemID & "," TSO.Write DataItem.Value & "," TSO.Write DataItem.DisplayValue & "," TSO.Write DataItem.LastValue & "," TSO.Write DataItem.WorkFlowID & "," TSO.Write DataItem.SOEID & "," TSO.Write DataItem.InDate & "," TSO.Write DataItem.OutDate & "," TSO.Write DataItem.FlowDefID & "," TSO.Write DataItem.AttribDataGUID & "," TSO.Write DataItem.AttribGUID & "," TSO.Write DataItem.AttribDefGUID & "," TSO.Write DataItem.SectionGUID & "," TSO.Write DataItem.SectionDefGUID & "," TSO.Write DataItem.ObjectGUID & "," TSO.Write DataItem.ObjectDefGUID & "," TSO.Write DataItem.ParentDataItemID & "," TSO.Write DataItem.FlowWritable & "," TSO.Write DataItem.Writable & "," TSO.Write DataItem.ItemType & "," TSO.WriteLine DataItem.ItemMiscData Next Next TSO.Close End Function Public Function ReadFile(ByVal sFile) Dim tmpString Dim File Set FSO = CreateObject("Scripting.FileSystemObject") ' Two Methods to read a file into a string ' Method 1 Set TSO = FSO.OpenTextFile(sFile, ForReading, True, TristateFalse) tmpString = TSO.ReadAll & Chr(10) & Chr(10) TSO.Close ' Method 2 'Set File = FSO.GetFile(sFile) 'Set TSO = File.OpenAsTextStream(ForReading) 'Do While Not TSO.AtEndOfStream ' tmpString = tmpString & TSO.ReadLine & Chr(10) 'Loop 'TSO.Close ReadFile = tmpString End Function