Skip to main content
Version: Classic

Output Management


Purpose and use

This document function can be used to transfer the generated file to one or more configurable endpoints.
This function can also be used to configure form letters or the serial creation of multiple documents based on a list of recipients, for example.

The individual actions are defined using primedocs Connect Commands.

Basic structure

<OutputConfiguration>
<DesktopOutput Name="Test Output 1">
<Fields>
<Text Name="Guid">
<Code>
function main() { return $.util.generateGuid(); }
</Code>
</Text>
<Text Name="GeneratedFileName">
<Code>
function main() {
var RecipientName = $("RecipientName");
return "X:\\documents\\Document_" + $("Guid") + "_" + RecipientName + ".docx"; }
</Code>
</Text>
</Fields>
<Commands>
<SaveFile field-FileName="GeneratedFileName" Overwrite="false" CreateFolder="false">
<Document />
</SaveFile>
</Commands>
</DesktopOutput>
<DesktopOutput Name="Test Output 2">
<Commands>
<SaveFile field-FileName="Forms.FullPath" Overwrite="false" CreateFolder="false">
<Document />
</SaveFile>
</Commands>
</DesktopOutput>
<DesktopSeriesOutput Name="Series Output">
<ForEach>
<SeriesTextReplacer Name="Default">
<Current Text="$current" />
<Total Text="$total" />
</SeriesTextReplacer>
<Commands>
<SaveFile FileName="C:\temp\sample_$current_of_$total.docx" Overwrite="true" replacer-FileName="Default">
<Document />
</SaveFile>
</Commands>
</ForEach>
<ForSeries>
<MergeAsPdf>
<Commands>
<SaveFile FileName="C:\temp\sample.pdf" Overwrite="true">
<Document />
</SaveFile>
<OpenFile FileName="C:\temp\sample.pdf" />
</Commands>
</MergeAsPdf>
</ForSeries>
</DesktopSeriesOutput>
</OutputConfiguration>

If the SelectecObjectId attribute is configured in an ObjectCollection within the Forms configuration, a DesktopSeriesOutput configuration is implicitly generated and a corresponding button is displayed in the Forms dialogue.

The optional DisableDefaultSeriesOutput attribute can be used to suppress this behaviour.


DesktopOutput

The resulting document can be sent to a specific endpoint using the DesktopOutput-elements.

Required attributes:

  • Name: The name is displayed as an additional button in the Forms interface when generating.

Elements:

  • Fields: To define dynamic data for an "output," fields can be defined in a similar way to the normal Fields function.
  • Commands: The commands determine which actions are performed. All commands from primedocs Connect are available.

Fields in Outputs

Fields in the output are calculated as soon as the corresponding output is activated.

The Output Fields allow a subset of the normal field function in combination with certain API calls.

<Fields>
<Text Name="Guid">
<Code>
function main() { return $.util.generateGuid(); }
</Code>
</Text>
<Text Name="StaticValue" Value="Test" />
<Text Name="StaticTranslatedValue" translate-Value="Fields.Key.StaticValue" />
<Text Name="GeneratedFileName">
<Code>
function main() {
var RecipientName = $("RecipientName");
return "X:\\documents\\Document_" + $("Guid") + "_" + RecipientName + ".docx";
}
</Code>
</Text>
</Fields>

Elements:

Text: Allows you to create a Text element. A Name must be set as the identifier.
The value can be set in the following ways:

  • Static via Value
  • Static, but with translation via translate-Value
  • Dynamic via Code

The Code element uses the same logic as the Fields, but with a simplified JavaScript API:

note

Only Text types can be retrieved and returned in this API. Access to fields with other types is not permitted.

FunctionReturn type
$.(…)Returns a text field.
$.get(…)Returns a text field.
$.getText(…)Returns a text field.
$.util.generateGuid()Generates a unique GUID.

The generated fields can then be used for the Commands via the field-FileName (etc.) syntax.


DesktopSeriesOutput

Serial generation can be started using the DesktopSeriesOutput-elements.

ℹ️ Info This option can only be executed in combination with a configured ObjectCollection including SelectedObjectId, as a defined list must be iterated.

Required attributes:

  • Name: The name is displayed as an additional button in the Forms interface when generating.

Elements:

  • ForEach: This element can be used to define actions for each serial document.
    • Example: A document should be saved for each recipient.
  • ForSeries: This element can be used to create a merged PDF for the entire series.
    • Example: A merged PDF is required for all recipients.

ForEach

  • This element can be used to define actions for each serial document.

Elements:

  • SeriesTextReplacer: This element can be used to map placeholders for the current element and the total number of documents to be generated. This makes it possible to create Document_26_of_87.docx. Only this element has access to the current “iterator” and the “total number”.
    • <Current Text="$current" /> means that the current number is expressed by the placeholder $current.
    • <Total Text="$total" /> means that the total number is expressed by the placeholder $total.
    • Multiple SeriesTextReplacer-s can be defined—all must have a unique Name attribute.
  • Commands: Similar to DesktopOutput, the commands are defined here (see: primedocs Connect)
    • In addition, you can access the replacer-FileName="Default" here.

ℹ️ Info Similar to dynamic access via field-FileName, these attributes can be iterated through again in the ForEach element using the replacer-[ATTRIBUTE].

“ForSeries”

This element allows you to map all documents as a single PDF using the MergeAsPdf element.

Commands can be defined within MergeAsPdf and the result is processed as a “PDF” document.