Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

Connect-File method

Updated on August 16, 2022

Use the Connect-File method to invoke a Connect File rule ( Rule-File-Connect rule type). The rule can create, add contents to, or close an output file.


This method has three parameters:

ConnectorName Enter the Connector Name (second key part) of a Connect File rule, an instance of the Rule-Connect-File rule type. The system uses the class of the step page as the first key part of the rule.
Operation Select to identify the source of output to be added to the file.
  • Write from HTML Stream Rule — An HTML rule.
  • Write from XML Stream Rule — An XML Stream rule.
  • Write from eForm — A Map eForm rule
  • Work Attachment — A work item attachment
  • Write from Clipboard Property — The value of a single property.
  • Write from Map Structured rule — The output data structure produced by a map structured rule.
  • Close File — No further output; close the file. (This is meaningful and necessary only when the Keep File Open check box is selected on a Connect File rule.
Parameter Identify the key of the Operation parameter.

Identify the property, key of the rule, or key of the work item attachment designated in the Operation field.

  • For Clipboard Property, enter a property reference, literal text, parameter, local variable, or complex function. Literal text must be surrounded by double quotes.
  • For HTML Stream rules, XML Stream rules, or Write from Map Structured rule, enter the second key part of the rule. The system uses the class of the step page (or the class of the activity) with rule resolution to find the rule. (For XML Stream rules, the third key part must be MapFrom.)
  • For eform rules, enter a valid Code-Pega-eForm page. Ensure that the pyEform property of this page contains the PDF content, in the form of a byte array.
  • For Work Attachment, enter the name of a valid page of class Data-WorkAttach-File.
  • Leave blank if the Operation parameter is Close File.


The Connect-File method works as follows:

  1. Using rule resolution, locates the Connect File rule.
  2. Uses information in the Service tab of the rule to identify the path and file name of the output file, and processing instructions.
  3. Locates the rule or other object identified by the Operation and Parameter.
  4. Opens the file if not already open, and appends the output.
  5. Generates the output using stream processing, map eform processing or map structured processing, if specified. If the map structured rule specifies a character encoding other than Default, output characters are converted to the specified character set using normal Java methods.
  6. Closes the file, unless the Keep File open option on the Connect File rule is selected.
  7. Updates the value on the clipboard of the status and status message properties identified in the rule.

If the Operation is Close File, steps 5 and 6 do not occur and the output file is closed.

Operation of this method is synchronous. Further processing in the activity does not resume until the file processing completes.

Checking the method status

This method updates the pxMethodStatus property. See How to test method results using a transition.


For an example using this method, see the Pega Community article How to write a file to the local file system using a file connector.

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us