Entry title doesn't update

System Information
  • Strapi Version: 4.4.3
  • Operating System:
  • Database: Postgress
  • Node Version: 16.17.0
  • NPM Version: 8.19.2
  • Yarn Version:

  • Create collection type XXX with relation one to one to YYY,
  • Relation YYY shows as ID
    image
  • Make a text field in the YYY and set it as entry title,
  • In XXX relation to YYY still show an ID
  • Delete relation in collection XXX - save,
  • Add again same relation in XXX to YYY - save,
  • Now relation correctly shows the text field as entry title
    image

Why is that? Why do I have to remove relation to update entry title. I wanted to update entry titles in all of my Collections, but deleting all relations will cause huge data loss.

EDIT
It looks like changing entry title doesn’t change metadata in schema object
image
before deleteing relation “mainField” showed “id”

1 Like

To whomever may find this post and is still looking for an answer:
In Strapi v4 the configuration for the entry title of a content type isnt stored in the code, it is stored in the database in a table called strapi_core_store_settings.
This table contains key-value pairs where the key references a given content type and the value is a JSON containing its settings.
When you update “entry title” of content type A – let’s say you set it to “title” – in the admin panel, you’re updating the “mainField” field in the JSON (value column) of content type A in the database, and from that moment on, any new relations created in strapi that reference content type A will use the field “title” as a view.
Nevertheless, this doesn’t update the mainField of existing relations. For that, you have to update the mainField of each relation referencing content type A.
So in the question above, the solution would follow these steps:

  • Update entry title of YYY to text_field (you can do it in the admin panel or in the database)
  • Update the JSON of the value column of XXX and change the mainField value of the relation to YYY from ID to text field.

if it’s small scale you can do it manually, otherwise a python script should do the trick.