2 minute read BPS Version: 2023.1.3.202

Overview

I got a request whether it would be possible to not only display All attachments after page load but also collapse the groups. This was one of those requests, which made me wonder, why I didn’t think of it myself. :)

After page load all attachment folders are collapsed.
After page load all attachment folders are collapsed.

Info: This post is based on Show all attachments after page load.

Implementation

All attachments display options

The updated function will allow you to choose from three different options to display the All attachments tab.

  • Collapse to folder names
    Folders are collapsed
  • Collapse to category (subfolder)
    Categories are collapsed, if they exist
  • All elements are expanded
    All attachments are displayed

Depending on your preferences you can choose from three different options to display the All attachments tab.

Basic implementation with fixed display option

The implementation is simple.

  1. Create a form rule in JavaScript mode.
  2. Copy the content of the ShowAllAttachments.js or ShowAllAttachments.min.js from the repository.
  3. Modify the last line of the code to match your need.
    • Collapse to folder names
      dkr.showAllAttachments.execute(0, 4, 0)
    • Collapse to category (subfolder)
      dkr.showAllAttachments.execute(0, 4, 1)
    • All elements are expanded
      dkr.showAllAttachments.execute(0, 4,null)
Creating the form rule and defining the collapsed levels.
Creating the form rule and defining the collapsed levels.

What’s left is to execute the form rule after page load.

Executing the form rule after page load.
Executing the form rule after page load.

Option 2: Form rule with a parameter

An alternative to the fixed display option is to make it configurable using a form rule parameter. If you want to display all elements without collapsing, than you need to pass Empty.

Same form rule, but with a parameter.
Same form rule, but with a parameter.

Option 3: HTML field

The last option is different from the previous, as this will make use of HTML field to execute the JavaScript. This way we can make use of the field matrix or other elements, to conditionally display the HTML and thereby executing the function.

If you are going to use this option, you need to remove the call to the execute function from the form rule itself.

Function `dkr.showAllAttachments.execute` is not executed in the form rule.
Function dkr.showAllAttachments.execute is not executed in the form rule.

Of course, you need to remove the form load from the on page load event, too.

The page load event does not call the form rule.
The page load event does not call the form rule.

The HTML field will invoke the form rule and call the execute function whenever the field will be visible. If you want to copy the below lines, make sure to use your form rule.

<script>
InvokeRule(#{BRUX:950:ID}#);
dkr.showAllAttachments.execute(0, 4,0);
</script>
Execution via an HTML field.
Execution via an HTML field.

Info: The name of the form rule in the screenshot is a bit misleading.

Folders and categories in all attachments

Using the Related attachments will allow you to display the documents any kind of of attachments. These may be parent/child workflows or they can be based on a query.

The first thing to do is activating the Related attachments for the attachment element in the form.

Activate the related attachments.
Activate the related attachments.

The official documentation already contains the most relevant information, if you really need it. The information in the blue info icon already provides the relevant information.

The info icon provides the expected column names.
The info icon provides the expected column names.

Unfortunately, there seems to be a mix up between the column names and their actual usage. The ElementName column is used for subfolder/category labels and Category for the file name.

ElementName and Category usage
ElementName and Category usage

Maybe someone can upvote my user voice: Related attachments: Column names are confusing.

Comments