ID Generation (Unique ID activity)

ID Generation (Unique ID activity)

Compose Enterprise is going through a design update. The illustrations on this page might be of the old design, but the information is up to date. Thank you for your patience during this update!

Norsk

You can associate unique ID numbers to every session of a running workflow in Compose. This is done by building a Unique ID element that generates IDs to your own requirements. Through the Unique ID activity in the workflow, you can connect Unique ID elements created in the Unique ID Builder. These ID numbers can then be added to form fields, in the titles of PDFs, in generated XMLs etc. In this user guide, you’ll learn how to create a unique ID, the difference between sequential and random ID types, how to connect a unique ID to a workflow, and how to add the ID number to the title of a PDF.

Build a Unique ID element

Click New Unique ID in the top menu. Give the unique ID a name, click OK, and double-click the unique ID to open the Unique ID Builder.

Customize the ID generation in the Properties panel. You need to set a Mount Point (which we will connect to in the workflow), a Type (sequential or random) and specify a Format. The mount point is just a reference text of your choosing. The ID generation type can be either Sequential, resulting in a sequential generation of IDs, say 01, 02, 03 etc., or Random, resulting in generation of random strings, aka. 240f6326-e849-4e05-bd92-b49f901f9c05.

We’re are using Java UUID (Universally Unique Identifier) to generate random unique IDs.

Ex:- UUID.randomUUID()

This has the fixed length as seen on the following example:

32 hex char + 4 hyphen char = 36 char.

Technical term (source: https://docs.oracle.com/javase/8/docs/api/java/util/UUID.html):

A UUID represent a 128-bit long value. 128 bit hex string there will be 128/4=32 char (each char is 4-bit long). In string format it also contains 4 ( - ). That’s why the length is 36“.

and with the fixed format as below.

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Ex:- 123e4567-e89b-42d3-a456-556642440000

 

The format depends on the type you’ve chosen. You may add pre- and postfixes to the format of both types. The format for sequences is <prefix>%<format>d<postfix>. For random IDs, the format is <prefix>%<format>s<postfix>. You may specify the amount of digits, say five digits for a sequential ID with the format %0,5d, which would render the ID number 00001. With a prefix and postfix for, say a random ID, the format NR_%s_NR could render the ID NR_56bbce10-31f2-46ea-802e-0fab22acae84_NR.

If you are planning on using the ID as part of a filename, please remove the comma from the format, i.e., on the form %05d instead of %0,5d. This is because, as the ID number passes 1000, the format %0,5d will render an ID number on the form 1,000, which will create an invalid filename because of the inclusion of the comma. The format %05d avoids this problem, as it will render an ID number on the form 01000.

In this user case, we choose a sequential type ID generation and we want the format to include a prefix and three digits – ID:%0,3d. Test the format by clicking the Test button and check that the first generated ID meets your requirements (in this case it should be ID:001).

For a sequential ID you may set the start point from which the sequence will begin. Press the Change button to set a new starting point for the sequence.

To be able to use the unique ID in a workflow, remember to Save and navigate back to the Organizer to start the unique ID by pressing Play.

Unique ID workflow activity

In this example, we’ll connect the unique ID to a workflow and add it to the title of a generated PDF. The ID number is accessible for pre-population anywhere in the workflow, so you can use it for many other purposes.

Construct a workflow with a Start Point, a Unique ID-, Form-, PDF Generation- and Send Email activity, and an End Point. If you’d like help with the basic configuration of these activities, check out the user guide Build a simple workflow.

Select the Unique ID activity and click Browse in the Properties panel to browse the workspace and connect the unique ID we created earlier.

You’ll see the Mount Point of the selected unique ID in the Mount Point input field, indicating that it is mounted to the workflow.

Note the name for the Unique ID activity (ID). It will be used as a placeholder in the filename of the generated PDF.

We’ve already connected the form activity to a form and generated a PDF based on the form in the PDF generation activity. We’ll now add the PDF as an attachement to an email and specify the PDF title with the ID. Select the Send Email activity, navigate to the Attachments tab and click Add Attachment.

Browse and select the PDF generation activity.

The PDF is by default named output.pdf. Under File Name, select the New radio button and enter a desired PDF filename. To include the generated ID in the filename we need to enter the Name of the unique ID activity in brackets {} to identify it as a placeholder. The full filename in our example becomes Summary_{ID}.pdf.

Save the draft, version the workflow and run it! When the first session of this workflow is completed, the title of the PDF attachment in the email activity will have the name Summary_ ID:101.pdf. The filename with the generated ID will make it easier to identify the files belonging to the same session.