Change record status: 
Project: 
Introduced in branch: 
10.3.x
Introduced in version: 
10.3.0
Description: 

Computed fields which are bundle fields can now be used in Views. Previously, attempting to declare such a field and use it in a view would cause a crash.

A computed field is a field whose value is generated by code when accessed, rather than stored in the database. A bundle field is one that is declared as only being on a particular bundle of an entity type, as opposed to a base field which is on all bundles. (Fields added in the admin UI are bundle fields, but the term 'bundle fields' usually means bundle fields that are defined in code.)

Computed bundle fields can now be declared the same way as stored fields. (They are not automatically declared to Views data: this is a matter for another core issue.)

      $views_data['my_entity_type']['computed_bundle_field'] = [
        'title' => $this->t('Computed Bundle Field'),
        'field' => [
          'id' => 'field',
          'default_formatter' => 'string',
          'field_name' => 'computed_bundle_field',
        ],
      ];

Note that computed fields can only be used as fields in Views: they cannot be used as filters, sorts, or arguments, because there is no data in the database for a query to work with.

Impacts: 
Module developers