entityDefs link conditions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • a.slyzhko
    Member
    • Oct 2023
    • 95

    entityDefs link conditions

    Hi there!
    I have custom Event type entity with many to many link with User entity. Here its link definition
    PHP Code:
    "attendees": {
        "type": "hasMany",
        "relationName": "cBusinessTripUser",
        "foreign": "cBusinessTrips",
        "entity": "User",
        "audited": false,
        "conditions": {
            "user.defaultTeamId!=": "665080eda8f96c718"
        },
        "additionalColumns": {
            "status": {
                "type": "varchar",
                "len": "36",
                "default": "None"
            }
        },
        "columnAttributeMap": {
            "status": "acceptanceStatus"
        }
    }
    It works perfectly fine for displaying info, but when I try to manipulate data of this link, I always get en error. I discovered, that when I open record view of an entity, it uses join user table, so condition works perfectly fine, but when I try to update data, no join user table is present in raw sql, so it fails. What should I change/add to negate the error?
    P.S. I know that I can add extra field defaultTeamId to middle table, but it will be db normalization, and defaultTeamId sometimes changes, so I will end up with inconsistent data. If there a way to add join every time this table is selected, it would be great solution!
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1606

    #2
    log-file would be helpful

    Comment


    • a.slyzhko
      a.slyzhko commented
      Editing a comment
      Log file says no column default_team_id in middle table, which is obvious. Question is how to perform join user table?
  • yuri
    Member
    • Mar 2014
    • 8453

    #3
    It's not possible. The "conditions" parameter is not for the middle table. Which I believe is enough. Otherwise, it should not be a relationship. It works for read by an incident, not by design.
    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...