FTP Connector Guide > Process Objects with FTP Connector > Event Target Process Objects
  

Event Target Process Objects

Event Target definitions enable you to work with process objects to write files and serialize delimited content.

File Writer

When you publish a connection that includes a file writer definition as an Event Target, Process Designer also creates a service.
The FileWriteTask process object contains the name of the target file, the relative file path (based on the event target's base directory) and the string content to write to the target.
<FileWriteTask>

<!-- file path, if required, which must be relative for FTP/SFTP -->
<filePath> documents </filePath>
<!-- target file name -->
<fileName> test.txt</fileName>

<!-- content format, which determines the applicability of other fields -->
<format>PlainText|Binary|Attachment|JSON|XML</format>

<!-- applies only if format is PlainText or Binary - if Binary, content is Base64-encoded string -->
<content>Test file content</content>

<!-- applies if content is XML or JSON, in which case, use object or objects -->
<object>process object</object>
<objects>a list of process objects</objects>

<!-- optional, peovide the ObjectName and listName -->
<objectName>order</objectName>
<listName>orders</listName>

</FileWriteTask>
Note: If the file or any folders in the path do not exist, they are automatically created.
For details on the FileInformation process object, see File Information Process Objects.

Delimited Content

When you publish a connection that contains a delimited content event target, Process Designer creates a service that you can use to serialize your process objects into a delimited file.
You can serialize both delimited content process objects, which represent the general model of a delimited content file, and custom process objects.

Serialize Custom Process Objects

The process objects created to handle delimited files in an Event Target are:
  1. 1Use SerializeToDelimitedContentTask to access the request object.
  2. 2Use SerializeToDelimitedContentResult to access the results of the serialization.
For example:
<SerializeToDelimitedContentTask>
<!-- for FTP/SFTP only -->
<host>127.0.0.1</host>

<fileName> users2.csv </fileName>
<filePath> CustomModelProcess </filePath>
<delimiter> ; </delimiter>
<skipHeaders> true </skipHeaders>
<customObjects>
<Email> bob@test.com </Email>
<Password> 222222 </Password>
<Phone_number> 333-3333-5554 </Phone_number>
<User_name> Bob </User_name>
</customObjects>
<customObjects>
<Email> bill@test.com </Email>
<Password> 3333 </Password>
<Phone_number> 444-222-111 </Phone_number>
<User_name> Bill </User_name> </customObjects>
<header>
<name> User_name </name>
<fieldIndex> 1 </fieldIndex>
</header>
<header>
<name> Phone_number </name>
<fieldIndex> 2 </fieldIndex>
</header>
<header>
<name> Password </name>
<fieldIndex> 3 </fieldIndex>
</header>
</SerializeToDelimitedContentTask>
The request should include the target file name, relative file path, and a list of custom objects.
Note: You can also provide delimited and text qualifier characters if you need to overwrite default values that are set in the event target's properties. For example, you might want to overwrite the skipHeaders attribute if you generate process objects one by one. In that case, you can write headers in the first record and then skip headers as you append all other records in the file.

Handling Headers

Process Designer can automatically serialize simple objects but skips complex fields (such as references and object lists) when using the custom process objects. The generated file includes a list of headers using the first process object's simple field names. Sometimes this method is useful but it has several disadvantages:
You can eliminate these disadvantages if you include a set of custom headers in a request object. Process Designer then uses the headers to generate delimited records with only the specified fields in the specified order.
Note: Use custom headers only if you serialize custom process objects. If you serialize a built-in delimited content process object, it already contains information about headers so there is no need to use custom headers.

Serialization Results

Whatever approach you take, after each file is processed, the results display:
For example:
<SerializeToDelimitedContentResult>
<message/>
<processedRecordsCount> 10 </processedRecordsCount>
<writtenRecordsCount> 8 </writtenRecordsCount>
<success> true </success>
<fileInfo> <lastModified> 2015-05-15T14:07:11.475Z </lastModified>
<dir> D:/MyDirectory/DelimitedFiles/CustomModelProcess </dir>
<name> users2 </ns7:name>
<path> D:/MyDirectory/DelimitedFiles/CustomModelProcess/users2.csv </path>
<fullName> users2.csv </fullName>
<ext> csv </ext>
<size> 116 </size>
</fileInfo>
</SerializeToDelimitedContentResult>