Data Structure Field

Data structure fields are used in the following cases:

  • AllColumns = False in the data structure entity. You then have to specify the fields which will make up the structure.
  • AllColumns = True in the data structure entity but you want to add additional fields which either have ExcludeFromAllFields = True in the entity or you want to use the UseLookupValue attribute to look up some other data.

Attributes

Caption Overrides a Caption defined in the source data entity field. If you need a different caption for the field than defined in the entity, you can define it here.
Field Select the source data entity field.
DefaultLookup Overrides a DefaultLookup attribute defined in the source data entity field. If you need a different lookup than defined in the source field, you can define it here.
UseLookupValue If True, the column will not contain data defined by the source field (defined in Field), but it will contain data returned by the lookup. The value defined in the Field attribute will be passed to the lookup as a parameter.

UseLookupValue Example

You have an Invoice entity, which contains fields Id, InvoiceNumber and refBusinessPartnerId. You are creating a report in which you want to display the invoice number and business partners’ name.

What you need to do is to create a simple data structure, which will contain the data entity Invoice. You add all the fields (explicitly) and you set the following attributes to the refBusinessPartnerId field:

Name BusinessPartner_Name
UseLookupValue True
DefaultLookup BusinessPartner

By doing this, the field will return the business partner’s name, instead of the Id, by looking up the name by the ID, which is originally contained in this field.

In reality, it will make the following SQL statement:

SELECT
    Id,
    InvoiceNumber,
    -- this is the beginning of the lookup produced subquery
    (SELECT BusinessPartner.Name 
        FROM BusinessPartner 
    WHERE 
        BusinessPartner.Id = Invoice.refBusinessPartnerId
    ) as BusinessPartner_Name
    -- end of lookup subquery
FROM
    Invoice