Error 500 No 'foreignMidKey'

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • rabii
    commented on 's reply
    Thanks shalmaxb

  • esforim
    commented on 's reply
    rabii just got himself a e-boyfriend, maybe e-catgirl

  • shalmaxb
    commented on 's reply
    rabii is also very kind

  • Bertomi
    replied
    Sorry. Yes code is work correctly. Than you.

    Leave a comment:


  • rabii
    commented on 's reply
    i am not Paulina mate ?
    anyway hope the code will work for you.
    let me know if you need any further help

  • Bertomi
    replied
    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.​

    Leave a comment:


  • Bertomi
    commented on 's reply
    @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.

  • rabii
    replied
    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

    Leave a comment:


  • Bertomi
    replied
    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​

    Leave a comment:


  • Bertomi
    commented on 's reply
    Dear Paulina
    Unfortunately no, I temporarily removed the field from the filter fields.

  • Paulina
    replied
    Hi Bertomi,
    did you find a solution?

    Leave a comment:


  • victor
    replied
    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.

    Leave a comment:


  • Bertomi
    replied
    victor
    Dear Victor.

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

    Leave a comment:


  • victor
    commented on 's reply
    @Bertomi,

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

  • Bertomi
    commented on 's reply
    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)"}
Working...