We can also create our own custom search criteria by checking the Build criteria with custom script check box. This presents you with a script editor to write our own Link Criteria expression. Not all Connectors support the Advanced Link Criteria, and the Connector documentation states whether Advanced Link Criteria is supported. See "Connectors" in IBM Tivoli Directory Integrator V7.1 Reference Guide.
The search expression that we build must comply with the syntax expected by the underlying system. In order to pass your search expression to the Connector, populate the ret.filter object with your string expression.
A simple JavaScript example for an SQL Connector is:
ret.filter = " ID LIKE '" + work.getString("Name") + "'";
This custom Link Criteria assumes an example where the data source has an attribute called ID (typically a column name) that we want to match with the Name attribute in the Work entry.
The most common error you get when using Link Criteria is:
ERROR> AssemblyLine x failed because No criteria can be built from input (no link criteria specified)
This error occurs when we have a Link Criteria that refers to an attribute that cannot be found during the Lookup. For example, with the following Link Criteria:
uid equals $w_uid
Link Criteria setup fails if w_uid is not present in the Work entry. This might be because it is not read from the input sources (for example, not in an Input Map, or missing from the input source) or is removed from the Work entry in a script. In other words, the function call work.getAttribute("w_uid") returns NULL.
One way to avoid this is to write code in the Before Execute Hook of the Lookup, Delete, or Update mode Connector that skips its operation when the Link Criteria cannot be resolved due to missing attributes. For example:
if (work.getAttribute("w_uid") == null) system.ignoreEntry();
Your business rules might require other processing, such as a skipEntry() call instead of ignoreEntry(), which causes the AssemblyLine to stop processing the current entry and begin from the top on a new iteration. The ignoreEntry() function simply skips the current Connector and continues with the rest of the AssemblyLine.
Parent topic: Link Criteria