Export object properties on workflow step

Hello everyone, 

I need to export some properties of an object to a txt or cvs file on a workflow step.

The exported file must also have a header line to be read correctly by a third-party application. Ie : 

Col1                                 Col2                                  Col3           

Property1value                Property2value                 Property3value

Does anyone have a scipt to do this ?

Thanks.

Thomas

Parents
  • Hi ThomasH,

    Here is a script that should give you a good idea how to accomplish your task. This uses commas to delimit, but to use tabs, simply replace the commas (",") with Chr(9) to insert a tab character. 

    Hope this points you in the right direction. 

    Option Explicit

    ' Get the Vendor (property 1023).
    Dim pdVendor
    pdVendor = PropertyValues.SearchForProperty( 1023 ).TypedValue.DisplayValue
    ' Get the InvDate (property 1053).
    Dim pdInvDate
    pdInvDate = PropertyValues.SearchForProperty( 1053 ).TypedValue.DisplayValue
    ' Get the InvNum (property 1055).
    Dim pdInvNum
    pdInvNum = PropertyValues.SearchForProperty( 1055 ).TypedValue.DisplayValue
    ' Get the PONum (property 1056).
    Dim pdPONum
    pdPONum = PropertyValues.SearchForProperty( 1056 ).TypedValue.DisplayValue
    ' Get the InvAmt (property 1054).
    Dim pdInvAmt
    pdInvDate = PropertyValues.SearchForProperty( 1054 ).TypedValue.DisplayValue
    ' Get the DueDate (property 1057).
    Dim pdDueDate
    pdDueDate = PropertyValues.SearchForProperty( 1057 ).TypedValue.DisplayValue
    ' Get the APType (property 1059).
    Dim pdAPType
    pdAPType = PropertyValues.SearchForProperty( 1059 ).TypedValue.DisplayValue
    ' Get the Customer (property 1021).
    Dim pdCustomer
    pdCustomer = PropertyValues.SearchForProperty( 1021 ).TypedValue.DisplayValue
    ' Get the Approver (property 1060).
    Dim pdApprover
    pdApprover = PropertyValues.SearchForProperty( 1060 ).TypedValue.DisplayValue
    ' Get the Description (property 1081).
    Dim pdDescription
    pdDescription = PropertyValues.SearchForProperty( 1081 ).TypedValue.DisplayValue
    '-------------------------------------------------------------------------------------------------
    ' Construct the output.
    Dim szOutput
    szOutput = pdVendor & "," & pdInvDate & "," & pdInvNum & "," & pdPONum & "," & pdInvAmt & "," & pdDueDate & "," & pdAPType & "," & pdCustomer & "," & pdApprover & "," & pdDescription

    Const ForWriting = 2
    Dim csvFilePath,csvColumns,objFSO,objCSVFile,i

    ' Create new CSV file
    csvFilePath ="C:\CSVTest\Test.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objCSVFile = objFSO.CreateTextFile(csvFilePath, ForWriting, True)

    ' Write comma delimited list of columns in new CSV file.
    ' First row of Columns
    csvColumns = "Vendor,InvDate,InvNum,PONum,InvAmt,DueDate,APType,Customer,Approver,Description"
    objCSVFile.Write csvColumns
    objCSVFile.Writeline

    objCSVFile.Write chr(34) & szOutput & chr(34)
    objCSVFile.writeline

Reply
  • Hi ThomasH,

    Here is a script that should give you a good idea how to accomplish your task. This uses commas to delimit, but to use tabs, simply replace the commas (",") with Chr(9) to insert a tab character. 

    Hope this points you in the right direction. 

    Option Explicit

    ' Get the Vendor (property 1023).
    Dim pdVendor
    pdVendor = PropertyValues.SearchForProperty( 1023 ).TypedValue.DisplayValue
    ' Get the InvDate (property 1053).
    Dim pdInvDate
    pdInvDate = PropertyValues.SearchForProperty( 1053 ).TypedValue.DisplayValue
    ' Get the InvNum (property 1055).
    Dim pdInvNum
    pdInvNum = PropertyValues.SearchForProperty( 1055 ).TypedValue.DisplayValue
    ' Get the PONum (property 1056).
    Dim pdPONum
    pdPONum = PropertyValues.SearchForProperty( 1056 ).TypedValue.DisplayValue
    ' Get the InvAmt (property 1054).
    Dim pdInvAmt
    pdInvDate = PropertyValues.SearchForProperty( 1054 ).TypedValue.DisplayValue
    ' Get the DueDate (property 1057).
    Dim pdDueDate
    pdDueDate = PropertyValues.SearchForProperty( 1057 ).TypedValue.DisplayValue
    ' Get the APType (property 1059).
    Dim pdAPType
    pdAPType = PropertyValues.SearchForProperty( 1059 ).TypedValue.DisplayValue
    ' Get the Customer (property 1021).
    Dim pdCustomer
    pdCustomer = PropertyValues.SearchForProperty( 1021 ).TypedValue.DisplayValue
    ' Get the Approver (property 1060).
    Dim pdApprover
    pdApprover = PropertyValues.SearchForProperty( 1060 ).TypedValue.DisplayValue
    ' Get the Description (property 1081).
    Dim pdDescription
    pdDescription = PropertyValues.SearchForProperty( 1081 ).TypedValue.DisplayValue
    '-------------------------------------------------------------------------------------------------
    ' Construct the output.
    Dim szOutput
    szOutput = pdVendor & "," & pdInvDate & "," & pdInvNum & "," & pdPONum & "," & pdInvAmt & "," & pdDueDate & "," & pdAPType & "," & pdCustomer & "," & pdApprover & "," & pdDescription

    Const ForWriting = 2
    Dim csvFilePath,csvColumns,objFSO,objCSVFile,i

    ' Create new CSV file
    csvFilePath ="C:\CSVTest\Test.csv"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objCSVFile = objFSO.CreateTextFile(csvFilePath, ForWriting, True)

    ' Write comma delimited list of columns in new CSV file.
    ' First row of Columns
    csvColumns = "Vendor,InvDate,InvNum,PONum,InvAmt,DueDate,APType,Customer,Approver,Description"
    objCSVFile.Write csvColumns
    objCSVFile.Writeline

    objCSVFile.Write chr(34) & szOutput & chr(34)
    objCSVFile.writeline

Children