Skip to main content

How-to: Pull Instruments, Items, Containers, or Entities into a Picklist

Issue: How can a list of all instruments, items, or entities be pulled into a picklist?

Solution:

  • The list_entities expression can be used to return a list of entity names for a particular type of entity (instruments, items, and containers are also considered entities)

  • The list_entities expression accepts three parameters:

    • sample_type: which would be name of the entity type to return

      • This is required

      • An example would be {{ list_entities('Generic sample') }} to return all entities of the Generic Sample entity type in the system

    • filters: which would be additional filters to apply to the list

      • This may include tags, matching part of a name, specific owners, created before or after, etc.

      • By default, no filters are applied

      • An example would be {{ list_entities('Instrument', filters={'instrument_type': 'Centrifuge'}) }} to return all entities of the Instrument entity type with a custom field instrument_type value of Centrifuge in the system

    • disaplyField: which would be the information for the entity returned

      • This can be the name, description, barcode, uuid, or a custom field value of the entities returned

      • This will default to name

      • An example would be {{ list_entities('Instrument', filters={'instrument_type': 'Centrifuge'}, displayField='My Field') to return the value in the custom field named My Field for all entities of the Instrument entity type with a custom field instrument_type value of Centrifuge in the system

  • The list entities expressions can be further modified or combined in the expression if needed

    • For example {{ list_entities('Instrument', filters={'instrument_type': 'InstrumentA'}) + list_entities('Instrument', filters={'instrument_type': 'InstrumentB'}) }} would return all entities of the Instrument entity type with a custom field instrument_type value of InstrumentA and InstrumentB in the system

    • For more information about the list_entities expression, including a full list of the available filters, see Section 5 of the L7|ESP Documentation <base url>/doc/expressions/expressions.html#lab7.sample.expression.list_entities

20452091908115-mceclip0.png
  • Note on performance: If the expected number of entities being returned is high, this expression will take a long time to return and may affect system performance. To ensure that this expression returns in a reasonable amount of time, ensure that the proper filters have been applied to only return the set of entities of interest.