Loop time-limited store

Loop time-limited store

The advanced, other workflow component, Loop time-limited store is linked with the Time-limited persistent storage in workflows. Such a time-limited storage can be used for storing temporary data, which can be used to rerun input files after an issue has been solved.

The workflow component, Loop time-limited store can be compared with the repeat element of the designer in the way that it loop through all stored items in the specified storage. In each iteration, one item from the store will be copied to the payload. The predefined workflow variable, interformng.persistentStore.key will contain the key of the current item.

Related workflow components are:
Delete from time-limited store Deletes an item from the time-limited store.
Payload to time-limited store Saves the current payload as an item in a time-limited store.
Time-limited store to payload Retrieves an item from a time-limited store.

The component has these parameters:


Time-limited store
This need to refer to the store of which you want to loop through all stored items. This is normally selected via a drop down list, but you can setup an XPath expression to select this if needed.

Output type
The output type i.e. the expected type of the item, that is retrieved.

Sort keys
Each stored item is identified by a unique key value. Here you can decide in which order the stored items should be processed. The possible values are:
Unsorted
This is default. The items will be processed in an unspecified order.
Ascending
With this value the items will be processed in ascending order according to the key value of the items.
Descending
With this value the items will be processed in descending order according to the key value of the items.

In practice, the component will first take a snapshot of the keys that exist in the store, then start the iteration. If items are added to the store while the loop is running, then those items will not be included in the iteration. If items are deleted from the store while this loop is running, then the deleted items will be skipped silently.
However, if the last item in the iteration is deleted during the loop, then one empty payload may be returned in the end. In this case the workflow variable “interformng.persistentStore.key” will be a blank string.

Below is an example of how this component can be used:
Example: Load all items from a time-limited store, merge each of them into a PDF file and delete the item from the store
In this example all items in a time-limited store are loaded and each of them are merged with a template into a PDF file and the item of the store is finally deleted.
The workflow looks like this:

Here the initial input is a file found in a folder, but this is irrelevant for this example.

Each of the other components are described in details below.
Loop time-limited store
The first component in the workflow is the loop time-limited store with the settings below:


It executes the workflow to the right of this component for each item found in the store: MyTempStorage.  The items are retrieved in ascending order according to the key used for saving the item in the store.

Each time the payload is updated with the retrieved item and the workflow variable, interformng.persistentStore.key is updated with the key of this item. If nothing has been retrieved, then the variable, interformng.persistentStore.key will be empty.
Choice element
The choice element is used as a condition to ensure, that we only create a PDF file (and delete the item from the time-persistent store) if something was retrieved from the store. That is done with the condition below:

Here we use the string() function to convert the contents of the variable to a string. This is done to ensure, that the comparison with an empty string is true if the variable, interformng.persistentStore.key contains either an empty string or null.

The When branch shows as Found with this setting:



Create PDF file
Now we know we have retrieved an item, so we can now create a PDF file (based on the demo invoice xml file) like below:


The || function concatenates the text to the left of the function with the text which is found to the right.

We could have used the workflow variable, interformng.persistentStore.key if needed to identify the retrieved item, but here we simply use the contents of the payload to name the PDF file we create.
Delete from time-limited persistent store
Now it is time to delete the item from the store, that we have just processed. That is done with the component, Delete from time-persistent store as below:

Here we reuse the key, interformng.persistentStore.key to refer to the item.



    • Related Articles

    • Delete from time-limited store

      The Advanced, other workflow component, Delete from time-limited store is related to the tenant setting, Time-limited persistent storage. With this component you can delete a document from the time-limited store, that you have previously saved into ...
    • Time-limited persistent storage in workflows

      Introduction Some customers are using the file system or the library to store input XML documents, in case they need to be re-processed later due to an error. Other customers use the file system or the library to temporarily store inputs that need to ...
    • Payload to time-limited store

      The Advanced, other workflow component, Payload to time-limited store is related to the tenant setting, Time-limited persistent storage. With this component you can temporarily store the current payload into a time-limited storage, that you have ...
    • Time-limited store to payload

      The Advanced, other workflow component, Time-limited store to payload is related to the tenant setting, Time-limited persistent storage. With this component you can load a stored document from a time-limited store into the current payload. Related ...
    • Date & Time Operations

      Handling dates and times in XPath is essential for printing timestamps, performing date arithmetic, formatting output, and conditioning elements based on time-based rules. This section covers these functions in depth. Printing the current date/time ...