How can I set the Name field automatically?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zoul
    Junior Member
    • Apr 2025
    • 12

    #1

    How can I set the Name field automatically?

    I have a custom Event Registration table that links Contacts with (custom) Events. Each row in the Event Registration table has two links, one leading to Contacts and one leading to Events: Contacts ↔︎ Event Registrations ↔︎ Events.

    Now I am designing a screen that would let users create new Event Registrations. I want them to be able to just pick a Contact and an Event, that’s all. But the Event Registration entity has also got the Name field derived from Base and that Name field is required. Which means that when a user only enters a Contact and an Event, the backend complains of a missing required field. What can I do? (Apart from forcing users to enter a name manually, that’s something I don’t want to do.)

    I tried setting up a pre-save formula that would set Name to the contact’s name, didn’t work. (Maybe the relationship isn’t established at that point yet?) Also tried, as a hack, to simply set the pre-save formula to something like “name = "foo"”, but that didn’t work either, backend still complains of a missing field. Why?

    I have also tried to mark the Name field as not required for the Event Registration entity, but in that case the backend fails with a 500.
    Last edited by zoul; 10-23-2025, 09:32 AM.
  • victor
    Active Community Member
    • Aug 2022
    • 1038

    #2
    zoul

    - Enable Debug mode: https://docs.espocrm.com/administrat...ng/#debug-mode.
    - Reproduce the error.
    - Provide part of the log with this error. EspoCRM log files are located in {ESPO_ROOT}/data/logs/ directory. Most errors are logger there.

    Additionally, provide more information, for example:
    - Screenshots of all Relationships between the entities you are writing about.
    - Step-by-step display on the screenshots what exactly the Users are trying to do.
    Last edited by victor; 10-23-2025, 09:47 AM.

    Comment

    • zoul
      Junior Member
      • Apr 2025
      • 12

      #3
      To be clear, I am not complaining about the 500 error. I think I need to work around the Name field being required. Therefore there is no error to be reproduced, the backend is expected to complain about the missing value for a required field.

      Comment

      • shalmaxb
        Senior Member
        • Mar 2015
        • 1763

        #4
        I do that often by the following construction (regarding your use case):

        1. Set a default value in the name field, so it would not be empty on saving, as it is a required field. For instance put there: "This field will be filled automatically"
        2. Set a formula, which concatenates the contact and event fields content and set it so it fills the name field, more or less so:
        name = string\concatenate(contactName, ' ', eventName);

        This will fill the field name on saving with a string "contact event". And as the name field has the default content, it will not throw an error because of an empty name field.
        You can even hide the name field, if you don`t want to display the default value. To display you could instead insert a new field where you display the concatenated string as well.

        If your contact or event field contains multiple links you should convert those to a text box before. If you would need that formula, I can provide.

        Comment

        • zoul
          Junior Member
          • Apr 2025
          • 12

          #5
          Setting a default value is a great hack that I didn’t think of, thank you very much!

          Comment

          Working...