Announcement

Collapse
No announcement yet.

Error 500 No 'foreignMidKey'

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error 500 No 'foreignMidKey'

    I updated Espo to version 7.4.3. In the case of filter conditions for one of the individual modules, I get this error: Error 500
    No 'foreignMidKey' parameter defined in the relation 'csatolasok'. The related entity link type is Parent-to-Children. Where should foreignMidKey be? Please help me.​

  • #2
    Hi,
    From witch version have you upgrade espocrm?
    in custom metadata/entityDefs/


    what do you mean “n the case of filter conditions”, when you make a search from front-end?

    have try to make a rebuild ? And too a clear cache ?

    Maybe, you can post the metadata json here for see.

    but in last of the last chance, you can remove the relation and make it again. (Not tested, at your own risk)
    Last edited by item; 04-19-2023, 02:48 PM.

    Comment


    • #3
      Hi Bertomi,

      Tell me please:
      - Have you tried doing a CLI Rebuild: https://docs.espocrm.com/administrat...mands/#rebuild or even Hard Rebuild: https://docs.espocrm.com/administrat.../#hard-rebuild after upgrade?
      - What version of EspoCRM did you upgrade from to 7.4.3, what PHP version do you have?
      - Send error logs that you encounter. By default log files are created in {ESPO_ROOT}/data/logs/ directory.
      Last edited by victor; 04-20-2023, 12:34 PM.

      Comment


      • Bertomi
        Bertomi commented
        Editing a comment
        Hi Victor.

        Thanks to reply.
        Yes, I tried rebuilding and hard rebuilding as well. Unfortunately, it didn't help. In the LOG, there are only the two lines below, which I don't think are related to this problem. Unfortunately, I haven't found a solution yet. The error occurs when applying a filter field to the entity.
        I am attaching the contents of the LOG.

        [2023-04-24 02:02:02] ERROR: Uncaught Exception PDOException: "SQLSTATE[HY000] [2002] No such file or directory" at /volume1/web/myespo/application/Espo/ORM/PDO/MysqlPDOFactory.php line 73 {"exception":"[object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /volume1/web/myespo/application/Espo/ORM/PDO/MysqlPDOFactory.php:73)"}

        [2023-04-24 02:03:01] ERROR: Uncaught Exception PDOException: "SQLSTATE[HY000] [2002] No such file or directory" at /volume1/web/myespo/application/Espo/ORM/PDO/MysqlPDOFactory.php line 73 {"exception":"[object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /volume1/web/myespo/application/Espo/ORM/PDO/MysqlPDOFactory.php:73)"}

      • victor
        victor commented
        Editing a comment
        @Bertomi,

        Please answer this question:
        - What version of EspoCRM did you upgrade from to 7.4.3, what PHP version do you have?

    • #4
      victor
      Dear Victor.

      I updated espocrm to version 7.3.3, my PHP version is 8.0.

      Comment


      • #5
        Bertomi,

        It seems that you have deleted some relationship (or deleted and created a similar one, and the fields in Layouts remained from the old relationship).
        - Try to remove the relationship connecting these entities.
        - Remove all interconnected fields between them from all Layouts (especially from Layouts -> Search Filters) and from the Entity Manager (pay special attention to fields with the Foreign type).​
        - Make Rebuild.
        ​​- Recreate the relationships and required fields, make Rebuild again.

        Comment


        • #6
          Hi Bertomi,
          did you find a solution?

          Comment


          • Bertomi
            Bertomi commented
            Editing a comment
            Dear Paulina
            Unfortunately no, I temporarily removed the field from the filter fields.

        • #7
          Paulina

          Dear Paulina. Can I ask you for a little help?
          I have two custom entities. One is called materials, the other is called order. Materials have a one-to-many relationship with the order. There is a number field in the order entities, the value of which I would like to add to the value in the same number field of the related materials entity when the record is updated. Unfortunately, I can't do it using a formula. If you could help me, I would be very grateful.
          Thanks Thomas​

          Comment


          • #8
            hey Bertomi

            It is easy to achieve such thing using formula. i assume that when a material entity is changed (updated) you wanted to update all its related orders entities (mainly the field number) correct? if yes this is how you can achieve it using formula:

            PHP Code:
            // Trigger this when the name is changed and entity is not new - only when updated
            ifThen(!entity\isNew() && entity\isAttributeChanged('name'),
                
                
            // Get the count for next function record\findRelatedMany()
                
            $count record\count('Order''materialId='id);
                
                
            // Fetch all related orders for current material entity
                
            $relatedOrders record\findRelatedMany('Material'id'orders'$count'createdAt''desc');
                
                
            $i 0;
                
                
            // Loop through the orders and update the number field as you wish
                
            while(
                    
            $i array\length($relatedOrders),
                    (
                        
            // just as example will loop through all related orders and update number field to 127.
                        
            record\update('Order'array\at($relatedOrders$i), 'number'127);
                        
            $i $i 1;
                    )
                );
            )
            ​ 
            Please keep in mind that you need to change things to their correct name like the name of the link between material and orders (i assumed it is orders).

            Hope this helps
            Rabii
            Web Dev

            Comment


            • Bertomi
              Bertomi commented
              Editing a comment
              @Paulina.

              Thank you very much. I'll take a look at the weekend and write back to see if I managed to solve it. You are really very kind.

          • #9
            Paulina

            Dear Paulina.

            Thank you very much. I'll take a look at the weekend and write back to see if I managed to solve it. You are really very kind.​

            Comment


            • shalmaxb
              shalmaxb commented
              Editing a comment
              rabii is also very kind

            • esforim
              esforim commented
              Editing a comment
              rabii just got himself a e-boyfriend, maybe e-catgirl

            • rabii
              rabii commented
              Editing a comment
              Thanks shalmaxb

          • #10
            Sorry. Yes code is work correctly. Than you.

            Comment

            Working...
            X