I am stuck on the script that pulls orders to be delivered and writes them to a CSV file.
1. Create File
2. PlanetPress Database pulls the data using a SQL script.
3. Change emulation to database
4. Set Job variables from SQL which can be seen the deliveries in the debug message window.
5. Branch
6. Create Metadata using a generic PDF form
7. Change Elumation to CSV (is this needed?)
8. The VBscript below to dump the results to a CSV. It creates the headers but no detail from the captured variables is written to the CSV. I "borrowed" this script from elsewhere in this form and I confess I don't understand the MetaData relationship to this.
'this script creates a CSV file containing deliveries
Option Explicit
Dim MyMeta, x, MyCSVLine, FSO, ft
Set MyMeta = CreateObject("MetaDataLib.MetaFile")
MyMeta.LoadFromFile(Watch.GetMetadataFileName)
'create CSV
Set FSO = CreateObject("Scripting.FileSystemObject")
Set ft = FSO.OpenTextFile("C:\Users\ddms_user\Desktop\MNFEXC.CSV",2,True)
ft.WriteLine("Distribution_Center,Route,Delivery_#,PO_#,Type,Delivery_Date,Account,Customer_Name,Site_Address_1,Site_City,Site_State,Site_Zip,Product_Qty,Product_Name")
'for all documents in group 0
For x = 1 to MyMeta.Job.Group(0).Count
'add new CSV line
MyCSVLine = MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Distribution_Center}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Route}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Delivery_}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{PO_}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Type}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Delivery_Date}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Account}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Customer_Name}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Site_Address_1}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Site_City}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Site_State}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Site_Zip}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Product_Qty}") +","+ _
MyMeta.Job.Group(0).Document(x-1).FieldByName("%{Product_Name}") +","+ _
MyMeta.Job.Group(0).Document(x-1).AttributeByName("SelectedIndexInJob") + ";" + _
MyMeta.Job.Group(0).Document(x-1).AttributeByName("SelectedIndexInGroup")
ft.WriteLine(MyCSVLine)
Next
ft.Close
Set FSO = Nothing
Set MyMeta = Nothing