SearchTask (Integration function)

The SearchTask (Integration function) function allows you to query content from the Lobster Data Platform / Orchestration database (see Search API) in the mapping (phase 3) of a profile.

The search query is defined via the XML structure of a SearchTask object in parameter a, which can be built and tested interactively with the Search builder.

The XML structure can refer in the syntax @PARAM_X@ (with X from {B,C,D,E,F,G,H,I,J}) to the values of the optional parameters b-j from the function call.

Similarly, the syntax @VARIABLENNAME@ can be used to access the values of variables from the context of the profile.

The return value of the function is always the search result of a specific SearchResult object (SearchResult, TupleSearchResult or CsvSearchResult, see Search types) as text in XML format.

The optional parameter k can be used to parse this structure into a named DOM object, e.g. to evaluate this object with the function get value from XML () using XPath expressions.

images/download/attachments/201674109/image2021-9-23_15-48-12-version-1-modificationdate-1747044403439-api-v2.png

Parameter

Parameter

Description

Example

Note

a

XML structure of a SearchTask object

SearchTask
<?xml version="1.0" encoding="UTF-8"?>
<core:SearchTask ... entity="base:User">
<base:LobsterDataLoginRequest userName="admin" selectedRole="1" selectedCompany="1"/>
<core:TupleSearch>
<core:SimplePropertySearch projection="address.name1" compareType="=="/>
<core:PropertyProjection property="username"/>
<groupBy/>
</core:TupleSearch>
</core:SearchTask>
  • This search will use a Tuple search to find the accounts of all Users that do not have a name (address.name1) in the address and return a list of usernames (username).

A 'query' can be created and tested interactively with the Search builder. The XML structure of the SearchTask object is then displayed in the XML tab. This query definition can then simply be pasted via the clipboard as a static value for parameter a and edited if necessary.

Often – in contrast to the very simple example on the left – data from the runtime context in the profile must be included in the search so that it delivers the 'right' results. For this purpose, the XML can be applied to variables or parameters whose values are inserted at runtime from the context of the profile call.

Especially for more complex application cases, it can be helpful to integrate the XML structure of the SearchTask object into the target structure of the profile, so that the 'search' can be linked to source data via mapping and dynamically constructed at runtime. Then parameter a is filled using the function create xml from node()(see a more detailed example below). Even then the XML definition can include parameters and variables.

b-j

Parameters which – similar to regular variables between two '@' characters – can be addressed in the XML definition of the search

SearchTask
<?xml version="1.0" encoding="UTF-8"?>
<core:SearchTask ... entity="base:User">
<base:LobsterDataLoginRequest userName="admin" selectedRole="501" selectedCompany="@MSG_CALL_SCM_Company_id@"/>
<core:TupleSearch>
<core:SimplePropertySearch projection="@PARAM_B@" compareType="=="/>
<core:PropertyProjection property="@PARAM_C@"/>
<groupBy/>
</core:TupleSearch>
</core:SearchTask>

Based on the above example, parameters and variables were inserted here:

  • The variable MSG_CALL_SCM_Company_id defines the company for the login context of the query.

  • Parameter b (PARAM_B) defines the field of the user account to be checked against 'empty'.

  • Parameter c (PARAM_C) defines the field of the user account that should appear in the result.

To get the same search results as in the static case above, the following conditions must be met:

  • The profile call must be made in the login context of the company with ID 1, so that the variable MSG_CALL_SCM_Company_id has the value 1.

  • When calling the function, the parameters b and c must return the following text values:

    • PARAM_B: address.name1

    • PARAM_C: username

Examples