Wiki

Scale Your Enterprise

User Tools

Site Tools


bw:file_writer_tool

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bw:file_writer_tool [2019/01/02 11:49]
_deletedUser4_ created
bw:file_writer_tool [2022/08/02 15:29] (current)
akoehler
Line 1: Line 1:
-====== Introduction ======+====== Introduction (File Writer)======
  
-This document describes the use of the “File Writer” tool in Bizweaver. Information regarding the associated File Operations and File Reader tools is found in separate documents+This page describes the use of the “File Writer” tool in Bizweaver. Information regarding the associated File Operations and File Reader tools is found in separate documents.
- +
-====== Audience ====== +
- +
-This document is intended for developers of Bizweaver workflows. +
- +
-====== Related Documents ====== +
- +
-The following documents contain additional information that may be helpful with the development of Bizweaver workflows. +
- +
-  * [[bw:application_introduction|Application Introduction]] +
-  * Bizweaver – Looping Tool +
-  * [[bw:using_variables|Using Variables]] +
-  * Bizweaver – Webservice Tool +
-  * [[bw:file_operations_tool|File Operations Tool]] +
-  * [[bw:file_reader_tool|File Reader Tool]] +
- +
-====== General Workflow Step Information ====== +
- +
-  - Each workflow step must have a unique **Name**. +
-    - The application will assign a default name, but we recommend that you change the name to something that helps you understand the purpose of the step as it is used in other steps. +
-    - The name cannot have spaces or special characters other than and underscore (_) +
-  - Enter an optional **Description** to provide any additional information that may be helpful to understanding the step. +
-  - Press <**F4**> to find and use values from previous workflow steps.+
  
 ====== File Writer Tool ====== ====== File Writer Tool ======
Line 32: Line 9:
 There are three output methods available: Datasource, Custom String, and Binary. There are three output methods available: Datasource, Custom String, and Binary.
  
-**Note for Datasource and Binary outputs**+<WRAP center round help 80%> 
 +**Note for Datasource and Binary outputs.**
  
 If the same file name already exists in the target folder, it will automatically be over-written. The best way to address this situation if it might occur is to use a variable (such as a timestamp created with a VBScript step) to make the file name unique for each processing cycle. If the same file name already exists in the target folder, it will automatically be over-written. The best way to address this situation if it might occur is to use a variable (such as a timestamp created with a VBScript step) to make the file name unique for each processing cycle.
 +</WRAP>
 +
  
 ====== Datasource Output ====== ====== Datasource Output ======
Line 40: Line 20:
 The **Datasource** output option is used to write the input data set as it is received and create the file with data records only. Use the **Custom String** output method if header and footer sections, or custom column headings, are needed as well. No Bizweaver looping is required. The **Datasource** output option is used to write the input data set as it is received and create the file with data records only. Use the **Custom String** output method if header and footer sections, or custom column headings, are needed as well. No Bizweaver looping is required.
  
-{{:bw:frimage1.png?384x408}}+{{  :bw:fwimage1.png?384x408  }}
  
   - Enter the **Filename** (target folder and file name) for the output file.   - Enter the **Filename** (target folder and file name) for the output file.
Line 65: Line 45:
   * Include header and footer records   * Include header and footer records
  
 +<WRAP center round info>
 The File Writer tool must be inside a **Loop/End Loop** structure when using the Custom String option. This is because each record is processed individually as it is read from the source. If the Loop/End Loop structure is not used, you will only get the first record in your output file. The File Writer tool must be inside a **Loop/End Loop** structure when using the Custom String option. This is because each record is processed individually as it is read from the source. If the Loop/End Loop structure is not used, you will only get the first record in your output file.
  
-{{:bw:frimage2.png?384x408}}+</WRAP>
  
-<HTML><ol style="list-style-typedecimal;"></HTML> +{{  :bw:fwimage2.png?384x408  }} 
-<HTML><li></HTML><HTML><p></HTML>Enter the **Filename** (target folder and file name) for the output file.<HTML></p></HTML> + 
-<HTML><ol style="list-style-type: decimal;"></HTML> +  - Enter the **Filename** (target folder and file name) for the output file. 
-<HTML><li></HTML><HTML><p></HTML>Press <F4> to show variables from previous steps that can be used to create the file name.<HTML></p></HTML><HTML></li></HTML> +      - Press <F4> to show variables from previous steps that can be used to create the file name. 
-<HTML><li></HTML><HTML><p></HTML>The extension (e.g. csv, txt, etc.) must be included in the file name.<HTML></p></HTML><HTML></li></HTML> +      The extension (e.g. csv, txt, etc.) must be included in the file name. 
-<HTML><li></HTML><HTML><p></HTML>//**To create tab-delimited output, press Shift + Tab at the point where a delimiter is needed.**//<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +      //**To create tab-delimited output, press Shift + Tab at the point where a delimiter is needed.**// 
-<HTML></li></HTML> +  The **Header** section contains whatever values should be included in the first row(s) of the output file. 
-<HTML><li></HTML><HTML><p></HTML>The **Header** section contains whatever values should be included in the first row(s) of the output file.<HTML></p></HTML> +      - This section is only written once when the file is created 
-<HTML><ol start="4" style="list-style-type: decimal;"></HTML> +      This section is optional but must be included if the output file must include column headers. 
-<HTML><li></HTML><HTML><p></HTML>This section is only written once when the file is created<HTML></p></HTML><HTML></li></HTML> +      The appropriate delimiter value must separate column headers. 
-<HTML><li></HTML><HTML><p></HTML>This section is optional but must be included if the output file must include column headers.<HTML></p></HTML><HTML></li></HTML> +  The **Body** section contains the values for each data record coming from the input source. 
-<HTML><li></HTML><HTML><p></HTML>The appropriate delimiter value must separate column headers.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +      - The appropriate delimiter value must separate columns. 
-<HTML></li></HTML> +      In most cases the values in this section will be variables from the input source step. This is shown in the example image above. Press <F4> to list available steps, then click on the step name to see & select the desired values. 
-<HTML><li></HTML><HTML><p></HTML>The **Body** section contains the values for each data record coming from the input source.<HTML></p></HTML> +  The **Footer** section contains whatever values should be included as the last row(s) of the output file. 
-<HTML><ol start="7" style="list-style-type: decimal;"></HTML> +      - This section is only written once when the file is created 
-<HTML><li></HTML><HTML><p></HTML>The appropriate delimiter value must separate columns.<HTML></p></HTML><HTML></li></HTML> +      This section is optional. 
-<HTML><li></HTML><HTML><p></HTML>In most cases the values in this section will be variables from the input source step. This is shown in the example image above. Press <F4> to list available steps, then click on the step name to see & select the desired values.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +      The appropriate delimiter value must separate columns, if appropriate. 
-<HTML></li></HTML> +      An example of the use of this section might be a summary record for the contents of the file. 
-<HTML><li></HTML><HTML><p></HTML>The **Footer** section contains whatever values should be included as the last row(s) of the output file.<HTML></p></HTML> +  The output data can be placed into one, or more, files based on the “Grouped By”, “Each Record,” and “Append” options. 
-<HTML><ol start="9" style="list-style-type: decimal;"></HTML> +      - To create a single file, select the “Grouped By” option and leave the grouping value field blank, or use the “Append” option. See the notes below about the “Append” option. 
-<HTML><li></HTML><HTML><p></HTML>This section is only written once when the file is created<HTML></p></HTML><HTML></li></HTML> +      To create a unique file based on some value in the input data source, select “Grouped By.” Select a variable from the data source step and place it in the grouping value field. Press <F4> while in the field to see a list of data sources. Click on the appropriate data source to select the value. 
-<HTML><li></HTML><HTML><p></HTML>This section is optional.<HTML></p></HTML><HTML></li></HTML> +          - In this case, a variable from the data source must be used in the output file name to make each file unique. If this is not done, all records will be written into a single file. 
-<HTML><li></HTML><HTML><p></HTML>The appropriate delimiter value must separate columns, if appropriate.<HTML></p></HTML><HTML></li></HTML> +      To create a unique file for each input record, select “Create file for each record.” A separate file will be created for each record. 
-<HTML><li></HTML><HTML><p></HTML>An example of the use of this section might be a summary record for the contents of the file.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +<WRAP center round info
-<HTML></li></HTML> +When creating multiple files, a variable from the data source must be used in the output file name to make each file unique. If this is not done the specified file will be over-written each time a new “grouping” is found, and the file will only reflect the last record(s) processed. This applies for both the “Grouped By” and “Each Record” options. 
-<HTML><li></HTML><HTML><p></HTML>The output data can be placed into one, or more, files based on the “Grouped By”, “Each Record,” and “Append” options.<HTML></p></HTML> +</WRAP>
-<HTML><ol start="13" style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>To create a single file, select the “Grouped By” option and leave the grouping value field blank, or use the “Append” option. See the notes below about the “Append” option.<HTML></p></HTML><HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>To create a unique file based on some value in the input data source, select “Grouped By.” Select a variable from the data source step and place it in the grouping value field. Press <F4> while in the field to see a list of data sources. Click on the appropriate data source to select the value.<HTML></p></HTML> +
-<HTML><ol style="list-style-type: decimal;"></HTML> +
-<HTML><li></HTML><HTML><p></HTML>In this case, a variable from the data source must be used in the output file name to make each file unique. If this is not done, all records will be written into a single file.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
-<HTML></li></HTML> +
-<HTML><li></HTML><HTML><p></HTML>To create a unique file for each input record, select “Create file for each record.” A separate file will be created for each record.<HTML></p></HTML><HTML></li></HTML+
-<HTML><li></HTML><HTML><p></HTML>When creating multiple files, a variable from the data source must be used in the output file name to make each file unique. If this is not done the specified file will be over-written each time a new “grouping” is found, and the file will only reflect the last record(s) processed. This applies for both the “Grouped By” and “Each Record” options.<HTML></p></HTML><HTML></li></HTML><HTML></ol></HTML> +
-<HTML></li></HTML><HTML></ol></HTML>+
  
 ===== Append Option for Custom Output ===== ===== Append Option for Custom Output =====
Line 124: Line 96:
 The image below illustrates the record structure. The column headings in yellow are used to obtain the needed data. The image below illustrates the record structure. The column headings in yellow are used to obtain the needed data.
  
-{{:bw:frimage3.png?576x43}}+{{  :bw:fwimage3.png?576x43  }}
  
   - **ID** is the unique record ID in the table.   - **ID** is the unique record ID in the table.
Line 141: Line 113:
 The first step within the loop is to gather the detail for each specific record. The SQL statement to do this is: The first step within the loop is to gather the detail for each specific record. The SQL statement to do this is:
  
-> Select FileName, FileContent from TWBS_VGO_FormAttachments where [ID] =+<code sql> Select FileName, FileContent from TWBS_VGO_FormAttachments where [ID] =
  
-WorkFlow(SQLCommand1).Get({FIELD_ID})+WorkFlow(SQLCommand1).Get({FIELD_ID}) </code>
  
 The two values are then used in the File Writer step. The two values are then used in the File Writer step.
Line 150: Line 122:
   * The FileContent variable indicates what data is to be written out   * The FileContent variable indicates what data is to be written out
  
-{{:bw:frimage4.png?384x305}}+{{  :bw:fwimage4.png?384x305  }}
  
 This process occurs for each record passed into the loop. The recreated files are created in the designated folder using their original name. This process occurs for each record passed into the loop. The recreated files are created in the designated folder using their original name.
Line 160: Line 132:
 The Binary Output option can also be used to convert a signature captured in a Versago Form into a file on disk. The process is like the one described above but requires some additional pre-processing. The Binary Output option can also be used to convert a signature captured in a Versago Form into a file on disk. The process is like the one described above but requires some additional pre-processing.
  
-Signature data is stored in a column in the table used by the Versago Form. It is stored in a format that must be converted back to BASE64 before it can be used. This is done with a SQL Stored Procedure. The procedure does the conversion and stores the converted data in a new table. Following is a framework version of the procedure.+Signature data is stored in a column in the table used by the Versago Form. It is stored in a format that must be converted back to base64 before it can be used. There are two ways to approach this.
  
 +====Option 1====
 +When you know that a form will be capturing a signature, the conversion can be done in the **CustomPostExecute** procedure.  The framework code shown below can be included in the CustomPostExecute procedure, the framework procedure can be called from the CustomPostExecute procedure. The framework procedure does the conversion and stores the converted data in a new table. This can then be used by Bizweaver to create an image file for use in reports, etc. The advantage of this approach is that the signature images can be created automatically and stored on disk for future use. Following is a framework version of the procedure.
 +
 +<code sql>
 Create procedure [dbo].[SignatureImageConvert] @vgoRecNum int as Create procedure [dbo].[SignatureImageConvert] @vgoRecNum int as
  
 /* /*
- 
 12/AUG/2018 (R Unger / TWBS) 12/AUG/2018 (R Unger / TWBS)
- +Used to convert a signature image from text to base64 binary for use with Crystal Reports or to save as a disk file.
-Used to convert a signature image from text to BASE64 Binary for use with Crystal Reports or to save as a disk file. +
 -- --
- 
 @vgoRecNum and vgoRecNum are the primary key of the table. Change as needed. @vgoRecNum and vgoRecNum are the primary key of the table. Change as needed.
 +@ObjectID is the form ID.  Change as needed.
 F2_SigCapture is the Versago table. Change name as needed. F2_SigCapture is the Versago table. Change name as needed.
- 
 */ */
  
-declare @ConvString nvarchar(max) +declare @ConvString nvarchar(max), @ObjectID int 
 +set @ObjectID = 1
 -- --
- 
 -- Parse out image data from text string -- Parse out image data from text string
- 
 select @ConvString = substring(Signature,23,999999) select @ConvString = substring(Signature,23,999999)
- 
 from F2_SigCapture where vgoRecNum = @vgoRecNum from F2_SigCapture where vgoRecNum = @vgoRecNum
- 
 -- --
- +/* Convert image data to base64 Binary and insert into holding table named SignatureCapture. 
-/* Convert image data to BASE64 Binary and insert into holding table named SignatureCapture. Assumes a text field named “Name” is used to capture the signature name */ +Assumes a text field named “Name” is used to capture the signature name */
 insert into SignatureConvert insert into SignatureConvert
- 
 (ObjectID, ControlID, RecordId, FileName, FileType, FileContent, CreateDateTime) (ObjectID, ControlID, RecordId, FileName, FileType, FileContent, CreateDateTime)
- 
 select select
- +@Object,'SigCapture',@vgoRecNum, isnull(Name,'None'), 'image/png',
-1,'SigCapture',@vgoRecNum, isnull(Name,'None'), 'image/png', +
 cast('' as xml).value('xs:base64Binary(sql:variable("@convstring"))', 'varbinary(max)'), getdate() cast('' as xml).value('xs:base64Binary(sql:variable("@convstring"))', 'varbinary(max)'), getdate()
- 
 from F2_SigCapture where vgoRecNum = @vgoRecNum from F2_SigCapture where vgoRecNum = @vgoRecNum
 +</code>
  
 The image below illustrates the record structure of the “SignatureCapture” table. The column headings in yellow are used to obtain the needed data. The image below illustrates the record structure of the “SignatureCapture” table. The column headings in yellow are used to obtain the needed data.
  
-{{:bw:frimage5.png?576x55}}+{{  :bw:fwimage5.png  }}
  
 The conversion to disk file is then the same as described in Uploaded Versago Data section above. The conversion to disk file is then the same as described in Uploaded Versago Data section above.
 +
 +====Option 2====
 +The signature image can also be converted as needed in a Bizweaver workflow.  In this case a SQLCommand step is used to parse out the signature data using <code sql>substring(Signature,23,999999)</code> on the database column that holds the signature data.  This step feeds into a FileWriter step using the Binary Output option to convert the base64 data back to an image file, which is saved to disk for subsequent use.
 +
 +====File Writer Variables====
 +^Name         ^ Description         
 +| AppendData         | True or False if the append data radio button was selected        |
 +| BinaryData|      The value that was entered in the binary data section if any              |
 +|ColumnID| If create a file for records - grouped by is selected it will display the current record that is being grouped|
 +| CreateFileForAllRecords          | True or False if the create file for all records radio button was selected|
 +| CreateFileForGroupedRecords |True or False if the create a file for grouped records radio button was selected|
 +| CustomSeparator         |Will display the customer separator if any is selected|
 +| DataSourceWorkFlowID          |The source of the data that is being used in the file writer tool|
 +| EnableBinaryData |True or False if the binary data radio button is selected|
 +| EnableColumnHeaders          |True or False if the enable column headers radio button is selected|
 +|EnableDataSource          |True or False if there is a data source used|
 +| EnableStringBuilder |True or False if custom string radio button is selected|
 +| FileName          |The file location where the file that is being created is being saved with extension|
 +| FileType          |The file type that is selected ex. JSON,XML,Comma Seperated|
 +|FormattedStringBody |The value that was entered in the body section of the custom string if any|
 +| FormattedStringFooter         |The value that was entered in the footer section of the custom string if any|
 +| FormattedStringHeader         |The value that was entered in the header section of the custom string if any|
 +| StepMessage|During a failure the reason for failure will be populated here |
 +| StepStatus        |True or False|
 +
bw/file_writer_tool.1546447767.txt.gz · Last modified: 2019/01/02 11:49 by _deletedUser4_