reduce the amount of data returned from api call?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamie
    Senior Member
    • Aug 2025
    • 187

    #1

    reduce the amount of data returned from api call?

    i need to drastically reduce the amount of data returned by the entity lookup api call its returning every bit of data when i am only needing a small fraction of what's being returned

    Here is an example of the api call



    And to be clear, i don't want to reduce the amount of records, just the data in each record, i really only need what i am displaying and the id, not every single bit of data in the record that the table is now over 100 columns, you can imagine the delays for something i can't display

    yuri any thoughts on how to do this in an easy upgrade-friendly way?
  • emillod
    Active Community Member
    • Apr 2017
    • 1541

    #2
    You can use select param to specify which fields should be returned
    Last edited by emillod; Yesterday, 06:05 PM.

    Comment

    • jamie
      Senior Member
      • Aug 2025
      • 187

      #3
      Originally posted by emillod
      You can use the scope param to specify which fields should be returned
      This is an internal espo call for when it's looking up a linked records to insert the id into the current record, what i would call a foreign key lookup, so is this something i can control inside entity defs?

      Comment

      • a.slyzhko
        Senior Member
        • Oct 2023
        • 121

        #4
        You need to specify query param 'attributeSelect' with a list of needed attributes separated by comma. No attributeSelect means select all attributes

        Comment

        • jamie
          Senior Member
          • Aug 2025
          • 187

          #5
          Originally posted by a.slyzhko
          You need to specify query param 'attributeSelect' with a list of needed attributes separated by comma. No attributeSelect means select all attributes
          yeah that sounds like it might be the one i'd set that in entity defs? in the links section?

          Code:
          "workRecords": {
          "type": "hasMany",
          "relationName": "cServiceSpareWorkRecord",
          "foreign": "cServiceSpares",
          "entity": "WorkRecord",
          "audited": true,
          "isCustom": true
          },

          Comment

          • jamie
            Senior Member
            • Aug 2025
            • 187

            #6
            The main issue is that when we have a one-to-one relationship, it tends to bring in an extra 20,000 PLUS records. There are situations where one-to-one relationships are necessary, but when linking one entity to another, we really don’t need to pull in every single piece of data from the foreign record—only the data required to establish the link for the current record.

            Personally, this feels like a bug.

            Unless yuri knows a way to limit the number of records that the entity link lookup pulls into the front end?

            Comment

            • yuri
              EspoCRM product developer
              • Mar 2014
              • 9542

              #7
              > The main issue is that when we have a one-to-one relationship, it tends to bring in an extra 20,000 PLUS records.

              It's rather wrong definitions in your customization.

              The initial question is clearly and correctly answered in the post #4.
              If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

              Comment

              • yuri
                EspoCRM product developer
                • Mar 2014
                • 9542

                #8
                Places in the documentation where the 'select' parameter (or its alias 'attributeSelect ') is covered:

                1: https://docs.espocrm.com/development/api/crud/#list
                2: https://docs.espocrm.com/development...params/#select
                3: https://docs.espocrm.com/api/#/paths/Account/get
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment

                • jamie
                  Senior Member
                  • Aug 2025
                  • 187

                  #9
                  Originally posted by yuri
                  Places in the documentation where the 'select' parameter (or its alias 'attributeSelect ') is covered:

                  1: https://docs.espocrm.com/development/api/crud/#list
                  2: https://docs.espocrm.com/development...params/#select
                  3: https://docs.espocrm.com/api/#/paths/Account/get
                  So, what one of these do i need to do to fix my problem? What do I need to add to what file?

                  i need to specify exactly what gets returned when i try to link one entity to another

                  Comment

                  • yuri
                    EspoCRM product developer
                    • Mar 2014
                    • 9542

                    #10
                    Originally posted by a.slyzhko
                    You need to specify query param 'attributeSelect' with a list of needed attributes separated by comma. No attributeSelect means select all attributes
                    Query parameter. Query parameter is parameter specified in the URL, the way you already specified some (e.g. maxSize). a.slyzhko clearly stated what to do. Specify the attributes you need in query parameters, the attributes are separated by comma. Attributes correspond to the field names. It's all covered in the docs.
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment

                    • jamie
                      Senior Member
                      • Aug 2025
                      • 187

                      #11
                      Originally posted by yuri

                      Query parameter. A query parameter is a parameter specified in the URL, the way you already specified some (e.g., maxSize). a.slyzhko clearly stated what to do. Specify the attributes you need in query parameters; the attributes are separated by a comma. Attributes correspond to the field names. It's all covered in the docs.
                      i don't think you're understanding me. This is for when i am linking a record to another record, for example, i have a user, and i want to link it to a company i just posted the URL as an example.

                      Its not something i am creating it's something Espo is creating when its searching for the entities to link in a one-to-many, a many-to-many, or a one-to-one relationship if it was something i was developing yes i could just amend the url but this is something espo is doing and i need a way such as the list layout to limit the number of fileds its returning because its getting into the hundres and in particular the one to one relationships drasticly slow this down

                      i was hoping for something i could add to the endity relationship definition that would specify what fields to return when i am searching for a record to link

                      Comment

                      • yuri
                        EspoCRM product developer
                        • Mar 2014
                        • 9542

                        #12
                        The system does not fetch all attributes when selecting related records. It passes the 'attributeSelect' parameter set with fields available on the list layout. If it does not work for you, it could be some customization preventing this logic.

                        There's a relationship parameter that does the opposite, adds additional attributes. https://docs.espocrm.com/development...yattributelist
                        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                        Comment

                        • jamie
                          Senior Member
                          • Aug 2025
                          • 187

                          #13
                          Originally posted by yuri
                          The system does not fetch all attributes when selecting related records. It passes the 'attributeSelect' parameter set with fields available on the list layout. If it does not work for you, it could be some customization preventing this logic.

                          There's a relationship parameter that does the opposite, adds additional attributes. https://docs.espocrm.com/development...yattributelist
                          yeah that might be what i am looking for, so i would place this in the calling client def file or the one getting called?

                          Comment

                          • yuri
                            EspoCRM product developer
                            • Mar 2014
                            • 9542

                            #14
                            No, it's the opposite to what you need.

                            Maybe you set 'forceSelectAllAttributes' to true somewhere (in JS or JSON).
                            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                            Comment

                            Working...