# Create dynamic folders

A dynamic folder is created by making a specific entry to a folder's extra text tab. This text must be placed at the very beginning of the field and no other text can be entered there. To prevent the folder definition from being changed by mistake, only administrators should have write access to the folder. Other users can be given read access to it. This restriction also helps you avoid child entries being manually stored in the folder, since they would not be displayed.

Example of a dynamic folder statement

# !+[command]

The !+ command is replaced at runtime with the SQL statement SELECT * FROM for the database table dbo.objects. You can define the WHERE part of the query following the !+ command.

Example of an SQL statement with the '!+' command

Make sure you restrict your WHERE clause to the desired object types (assuming that they are not defined by the other search restrictions anyway). You should also exclude deleted entries, which are all entries with an objstatus not equal to 0.

# Query multiple tables

You can add other tables besides the objects table to the query. To do so, enter the other tables following a comma.

# Example 1

In this example, the query is restricted to the EMail metadata form (here: objmask = 2). The query also only searches for documents that have a specific name (here: Sorglos) in the From field (group name: ELOOUTL1).

!+ , objkeys WHERE objid = parentid
AND objmask = 2
AND (okeyname LIKE 'ELOOUTL1' AND okeydata LIKE '%sorglos')

# Example 2

The following example runs a query that sorts the entries by two different fields. This means the objkeys table must be read twice.

!+ , objkeys ok1, objkeys ok2 WHERE
objid=ok1.parentid AND objid=ok2.parentid AND
ok1.okeyno=0 AND ok2.okeyno=1 AND
objtype=254 AND objmask=5 AND
ok1.okeydata LIKE 'p1%'
ORDER BY ok2.okeydata, ok1.okeydata

An explanation of the individual lines of code:

The table objkeys is entered twice under the names ok1 and ok2. Remember to insert the leading comma, otherwise you will get a syntax error at the SQL level and the target folder will remain empty.

The objects base database table is linked to the two tables with the unique key objid.

We want to read two specific fields, rather than any two fields (the internal field numbers 0 and 1 correspond to the first and second fields in the form).

You only want to find documents with form type 5 that contain the value p1 in the first field.

The documents are then sorted by the second field. All identical entries are sorted by the first field.

Please note

The example searches for the contents of any field that start with p1, i. e. that a result is also generated if p1 occurs in a hidden field. However, the user will not see the corresponding field. In a production system, you should give the field a specific name.

Please note

The objid=parentid part of the query is required in any case. This connects the basic data table with the fields table. If you leave it out, you will get a long list of hits with entries that are wrong.

# !?[command]

A registered function must follow the !? command. The registered function must return a collection of IDs or GUIDs that correspond to a repository entry. You can learn what a registered function is and how to create them in the documentation Adding functionality with registered functions (opens new window).

Example of a dynamic folder:

!?RF_getSordIdsForDynamicWhere

A script file could look like this:

function RF_getSordIdsForDynamicWhere(ec, args)
{
        log.info("RF_getSordIdsForDynamicWhere(");
        var sord = args[0];
        log.info("sord=" + sord);
        var folderId = parseInt(args[1]);
        log.info("folderId=" + folderId);
        var db = new Packages.de.elo.ix.jscript.DBConnection();
        var ret = db.query("select objectid from relation where parentid=? order by objectid desc", folderId);
        log.info(")RF_getSordIdsForDynamicWhere" + ret);
        return ret;
}

# !=[command]

You can pass a saved search to the != command. However, the folder should be created automatically instead of manually. In the ELO Java Client, you can create a dynamic folder following a search via Ribbon > Search > Result > Dynamic folder.

To create a dynamic folder in your own ELOix application, you need to perform a search first. You will find the corresponding text in the field FindResult.dynamicFolder, which is provided through the ELOix interface.

Example:

FindResult fr = ixConnection.ix().findFirstSords();
ixConnection.ix().findClose(fr.getSearchId());
Sord sord = ixConnection.ix().checkoutSord();
sord.setDesc(fr.getDynamicFolder());
ixConnection.ix().checkinSord(sord,);

# Obsolete commands

The commands !! and !* are obsolete and are no longer supported in current ELO versions.

Last updated: August 15, 2024 at 8:37 AM