Announcement

Collapse
No announcement yet.

setting parent-field by formula causes error 404 in list- and detailview

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

  • setting parent-field by formula causes error 404 in list- and detailview

    Hello,
    we have created an entity from type "event", so we have a parent-field by default. Normally the value of this field is setted by formula:

    01: ifThenElse(entity\isNew() && parentId == null, parentType = 'Meeting');
    02: ifThenElse(entity\isNew() && parentId == null, parentName = entity\attributeFetched('meeting.id'));
    03: ifThenElse(entity\isNew() && parentId == null, parentId = entity\attributeFetched('meeting.id'));


    All looks ok. In the detail-view and in the list- view you see the name of the parent. But if we click on the link we get an 404 error. The link includes the name instead of the record-id. If we set the parent value manually, the link contains the record-id (the name will be shown). I've tried o lot of formula variants: with and without line 2 (see above), use of meeting_id and meetingid instead of meeting.id , use with and without subformula entity\attributeFetched. All tries have the same result: the content will be shown but the link isn't working. Can you help us?

  • #2
    I think the problem is the relationship between the new entity and the meeting-entity (n:1). I had took a look into the database. In all cases the parentid is filled by formula the database field "parent_id" is filled with the name of the parentid. In all cases the parentid is filled manually by usage of the GUI the database field "parent_id" is filled with the value of the database field "meeting_id" which contains the id value of the related meeting record.
    Also I had took a look into the coding. I'm not sure but the problem can be in the lines 68-72 of the file application\Espo\Core\Formula\attributeFetcher.php :
    if ($entity->getAttributeParam($attribute, 'isParentName') && $methodName == 'get') {
    $relationName = $entity->getAttributeParam($attribute, 'relation');
    if ($parent = $entity->get($relationName)) {
    return $parent->get('name');
    }


    I think that means that in all cases a formula uses the parentid the name will returned. But the Setting in the database needs the Id-value not the name...
    It seems to be a bug.

    Comment


    • #3
      Sorry, my fault!! Sometimes the problem is sitting in front of the screen...
      After the assignment I've made a comparison inside an ifThenElse-function. But I've used '=' instead of '=='. So the meetingName was assigned to the parentId. Very embarrassing....
      But now it works.

      Comment

      Working...
      X