K
K
Ken Jee2020-02-03 16:56:17
1C-Bitrix
Ken Jee, 2020-02-03 16:56:17

Why does an unknown field definition error occur when using a field from the runtime section in a filter?

Initially, there is an array of parameters to the filter and everything works.

$params = [
  'filter' => [
    '!=my_field_one_from_table' => 1,
  ]
];


But when a runtime section with an ExpressionField is added to the array...

$params = [
  'filter' => [
    '!=my_field_one_from_table' => 1,
    '=my_field_expression' => 0,
  ],
  'runtime' => [
    new ExpressionField(
      'my_field_expression',
      'LENGTH(my_field_two_from_table)',
      null,
      [ 'data_type' => 'integer' ]
    )
  ]
];


...Then an error occurs:
[Bitrix\Main\SystemException] 
Unknown field definition `my_field_expression` (my_field_expression) for MyCustom Entity. (100)
.../bitrix/modules/main/lib/entity/querychain.php:334


Everything seems to correspond to the bitrix docks:
1) https://dev.1c-bitrix.ru/learning/course/?COURSE_I...
2) https://dev.1c-bitrix.ru/learning/course/index.php ...

What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serginhold, 2020-02-03
@serginhold

Everything seems to correspond to the Bitrix docs

is it?
dock:
new Entity\ExpressionField('MAX_AGE', 'MAX(%s)', array('AGE_DAYS'))

your:
new ExpressionField( 'my_field_expression', 'LENGTH(my_field_two_from_table)', null, [ 'data_type' => 'integer' ])

find two differences in 2 and 3 parameters

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question