Answers.Body: <p>Actually it was as simple that Craft 5 migration automatically renamed some fields that had the same handle in matrixes. (fieldName<strong>2</strong> for example). So renaming in code and field type in control panel and making sure everything matches, fixed this.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-06-05T09:43:04.910Z
Answers.LastActivityDate: 2024-06-05T09:43:04.910Z
Answers.UserDisplayName: Tibbe
Body: <p>Im trying to query a list of matrix entries that have a related field but it doesn't work after updating to craft 5. Note that 'category' is not category field type, its a regular structured entry type.</p>
  <pre><code>{% set relatedDetails = entry.details
      .type('customDetails')
      .relatedTo({
          targetElement: block.category.one(),
          field: 'category'
      })
      .all()
  %}
  </code></pre>
  <p>returns 0 elements. However:</p>
  <pre><code>{% set unassignedDetails = entry.details.category(':empty:').all()%}
  </code></pre>
  <p>this works as intended, returning all nested entries that does not have that field assigned.</p>
  <p>How can I do it?</p>
  
Tags: <matrix><relatedto><nested>
Title: relatedTo craft 5 nested matrix entires
ThreadText: # relatedTo craft 5 nested matrix entires
  
  (Asked by: username_0 on 2024-06-05)
  
  Im trying to query a list of matrix entries that have a related field but it doesn't work after updating to craft 5. Note that 'category' is not category field type, its a regular structured entry type.
  
  ```
  {% set relatedDetails = entry.details
      .type('customDetails')
      .relatedTo({
          targetElement: block.category.one(),
          field: 'category'
      })
      .all()
  %}
  
  ```
  
  returns 0 elements. However:
  
  ```
  {% set unassignedDetails = entry.details.category(':empty:').all()%}
  
  ```
  
  this works as intended, returning all nested entries that does not have that field assigned.
  
  How can I do it?
  
  **Tags:** matrix, relatedto, nested
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2024-06-05. Score: 1
  
  Actually it was as simple that Craft 5 migration automatically renamed some fields that had the same handle in matrixes. (fieldName**2** for example). So renaming in code and field type in control panel and making sure everything matches, fixed this.
  
  
  ---
  
  