How to write a file to the local file system using a file connector
Your application can write files to the file system of the Process Commander server using Connect File rules. The generated file may contain the contents of an HTML or XML Stream rule, an eForm document, a work object attachment, or a clipboard property.
To implement a file connectorr:
- From the Application Explorer, create a new Connect File rule by selecting New > Rule > Integration-Connectors > Connect File.
- On the Connect File form, complete the necessary fields.
- Destination Path — Enter the location on the PRPC server for the file..
- File Name — Enter the name and extension of the file.
- If File Already Exists — Select the action to take if the specified file is already present in the location. The options are Fail, Append, or Overwrite.
- Keep File Open — Select to enable multiple iterations of the Connect-File method to write to the file, without having to open and reopen the file. If this option is selected, your application processing must eventually execute another Connect-File method with the Close File operation.
Note: Optionally, you can use the global resource setting syntax =PageName.Property for the File Name parameter.
- In a new or existing activity, add a step that invokes the Connect-File method.
In the step parameters section, fill in the following fields:
- ConnectorName — Using the SmartPrompt, select the Connect File rule you created earlier.
- Operation —Select the operation used to create the file. The options are:
Operation Parameter Write from HTML Stream Rule The name of an HTML rule instance defined in the step page class. Write from XML Stream Rule The name of an XML rule instance defined in the step page class. The third key part of this XML rule must be 'MapFrom'. Write from eForm The name of a page of class Code-Pega-eForm. Write from Work Attachment The name of a page of class Data-WorkAttach-File that holds the work object attachment. Write from Clipboard Property The name of a property (defined in step page class) with or without a leading period, or using the PageName.PropertyName method.
Closes the file to disable writing more content. Use when the Keep File Open option is selected in the Connect File rule to end processing of a file.
- Parameter — Enter the name of or reference to the input data source, as described in the Operation field. For example if the Operation is Write from HTML Stream Rule, then provide the StreamName of the html rule (Rule-Obj-HTML instance) in the Parameter field. If the input value contains a "." character, the system will look for a property rule. You can also input literal values by surrounding the text with double quotes, or complex function calls.
- If you are writing a file as a part of flow processing, add an Integrator shape to your flow that references the Activity rule you edited or created in step 3. The referenced activity rule should be of the type Connect.