Applies to version: 2021.1.x and above; author: Konrad Wojtycza
Form rules for attachments in WEBCON BPS allow you to receive information about attachments added to the workflow instances, without the need to know the WFDataAttachments table structure and to use SQL queries.
Rules will be presented using the “Change value of single field” action which has been configured for each rule separately (Fig.1). The sample configuration of the action with a rule is shown in Fig.2.
Fig. 1. The "Change value of single field" action on the Save path
Fig. 2. Configuration of the "Change value of single field" action
The configuration of subsequent rules operating on attachments is described below.
In the configuration of the Get attachments rule, indicate one of three available modes of selecting attachments whose ID will be returned.
A) Name and extension – allows you to select an attachment based on its name, extension and category.
When searching for an attachment, you can use special characters:
* - any string of characters
? - any single character
Example:
* .pdf - downloads all attachments with a .pdf extension
Agreement * - downloads all attachments that begin with "Agreement"
The Category field allows you to indicate the category in which attachments are searched for. In addition to categories defined in the process configuration, there are built-in options:
Fig. 3. An sample configuration of the first attachment selection mode in the Get Attachments rule
B) Regular expression – attachments will be selected from all attachments added to the instance based on the defined regular expression that filters names and extensions.
Fig. 4. Sample configuration of the second attachment selection mode in the Get Attachments rule
C) SQL query – the rule will return attachment’s IDs based on the defined SQL query. In the example, the rule will return the ID of attachments created by the currently logged in user.
Fig. 5. Sample configuration of the third attachment selection mode in the Get Attachments rule
The Attachments count rule will return the number of attachments added to the currently edited instance.
Fig. 6. Configuraton of the Attachments count rule within the action
When configuring the File name rule, provide the attachment’s ID, the name of which should be returned. To do this, the value returned by the nested Get attachments rule was used as a rule parameter, which will return the ID of the latest attachment in the .jpg format. The rule operates on a single attachment’s ID – an error will be returned if you try to enter more than one identifier.
Fig. 7. Configuration of the File name rule within the action
Fig. 8. Configuration of the Get attachments rule for the File name rule
Configuration of the Content type (Fig.9) rule (as the File name rule) operates on a single attachment’s ID. The Content type rule returns the internet media (MIME) attachment type which is a two-part identifier for files format used on the internet.
Fig. 9. Configuration of the Content type rule within the action
The Content as Base64 operates on a single attachment’s ID as a parameter. It returns the attachment content in Base64 transport encoding.
Fig. 10. Configuration of the Content as Base64 rule within the action
The effect of the above-described rules is visible in Fig . 11.
Fig. 11. The effect of the form rules described in the article
Form rules operating on attachments increase the wide range of form rules available for use in WEBCON BPS and allow for easier retrieval of information about attachments from the form level, without the need to know the WFDataAttachmets table, which stores information about attachments.