core:FindEntityAttribute (Preprocessor)

The FindEntityAttribute preprocessor is used to access the ID or another value of an entity and assign it to a specific target attribute (XML attribute) of another entity during an import.

For this purpose, the preprocessor must be placed inside the XML node of the object structure whose attribute it is to set. It contains a search node that can be expressed as a Search or Tuple search.

  • From a Search, the ID (id ) property always defines the a value for the target attribute.

  • To assign a value other than the ID (id), exactly one projection can be specified instead of the ISearchProjection node to define a single-column Tuple search.

In both cases the first result defines the value of the target attribute.

The following structure from the template preProcessor:FindEntityAttribute (see Lobster SCM templates) can be merged directly into the target position of an import structure .

images/download/attachments/58590324/image2020-9-28_14-8-2-version-1-modificationdate-1601294883983-api-v2.png

Parameter

Type

Meaning

Content (fixed value/example)

xsi:type 

String attribute

type of preprocessor

core:FindEntityAttribute

type

String attribute

entity type for the Search to be performed

base:Role
targetAttribute

String attribute

name of the target attribute whose value is to be set

role

search

Subnode

defines a search for the entity type specified by type

see example below


Example:

A guest user (see Guest users) for the company 'MY COMPANY' is to be created by a Single import, which should be owned by the same company account (ownerId) as the company account 'MY COMPANY'.

<?xml version="1.0" encoding="UTF-8"?>
<core:Import ... xmlns:base="SCM.BASE" action="CREATE">
<base:GuestUser loginToken="DEMO_GUEST_USER_TOKEN" active="true" locale="de" roleId="2201" maxLogins="3" loginCount="0" emailAddress="user@madeup.compa.ny" maxConcurrentSessions="1">
<!-- Assign company account for guest user by attribute companyId -->
<preProcessor xsi:type="core:FindEntityAttribute" type="base:CompanyAccount" targetAttribute="companyId">
<search>
<core:SimplePropertySearch projection="address.name1" compareType="==" stringValue="MY COMPANY"></core:SimplePropertySearch>
</search>
</preProcessor>
<!-- Assign owner of company account as owner of guest user account by attribute ownerId -->
<preProcessor xsi:type="core:FindEntityAttribute" type="base:CompanyAccount" targetAttribute="ownerId">
<search>
<core:SimplePropertySearch projection="address.name1" compareType="==" stringValue="MY COMPANY"></core:SimplePropertySearch>
<core:PropertyProjection property="ownerId"></core:PropertyProjection>
</search>
</preProcessor>
</base:GuestUser>
</core:Import>
  • The first preprocessor performs a Search for a company account whose name (address.name1) is 'MY COMPANY'. Its ID (id) is assigned to the company field (XML attribute companyID) of the guest user.

  • The second preprocessor performs a Tuple search for a company account with the same criteria, but specifies a projection for the owner field (ownerId). This projection is assigned to the owner field (XML attribute ownerId) for the guest user.