Announcement

Collapse
No announcement yet.

List Report - Advanced Pack - cannot take infos from "Contact"

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

  • List Report - Advanced Pack - cannot take infos from "Contact"

    Hi all,

    I'd like to create some list-reports with the Advanced Pack.

    We have "Contacts" (standard entity) and also "Vehicles" (self created entity)
    each contact can have several tasks
    each vehicle can have several tasks


    When I create a report, under the Filters, I can select Filters from Contacts - so the relationship seems to be there (not yet to Vehicles, don't know why...).

    But, when I'd like to select, what should be on the report under the Columns, I can only select "refers to", and fields from "created.by", "company", "changed.by", and "assigned.user" and the fields in the tasks itself...
    But I cannot select fields from Contacts and Vehicles..., why?

    I need a report, which is showing me the tasks with it's fields, but also, the assigned user - and not only the "refers to" with the link, I need a custom field, the "customer number" and the "vehicle number"...

    how can I do that? what for additional relationships do I need to setup, that "Contacts" and "Vehicles" also shows up in the Columns?

  • #2
    Hi Chris,

    has-many links are not supported as column in list reports.

    You can create a list report from Task where you can add columns from entities through a has-one link type.

    Comment


    • #3
      Why many?

      each task is only assigned to one contact (but a contact can have several tasks...)

      when I make the list report with task (so each task is getting a line on the report), I can select relies to (I think is correcht, in german it is „Bezieht sich auf“), which is a contact - so this link works! Now I just need another field from this contact, to which it relies to (and as written, the system sees and understand, to which contact it relies...) - so there shouldn‘t be an about the link...?

      Comment


      • #4
        I've just made a test, created a company and created a new task, assigned to the company.

        If I know create a Report, in the columns I can select "Bezieht sich auf", all the fields from the Company, including things like website etc., and also all the fields from the task itself...
        it creates a proper list with all the task, also the ones, which are assigned to a a Contact, on these tasks, the rows with the informatin from a company just stay emtpy - as epected, so all good.

        So why I cannot select the fields from the Contact? I don't see a difference, if the task is assigned to a company or to a user...

        Comment


        • #5
          Foreign field of Link type? Because of some technical constraints it's not supported. Maybe in future.

          I'm not sure if I understood what you.
          Last edited by yuri; 02-20-2018, 07:48 PM.

          Comment


          • #6
            ok, let's try to explain.

            When I create a new task, I can select "Bezieht sich auf", according to the entity manager, this is the "parent".
            in this parent, I can select a "Firma" - english "account", but can also select a "Kontakt" - in english a "contact" or some others. Right next to this field, you than can select, to which account or contact the tasks relate to.

            So every tasks, can always only be realted to "one account", or "one contact" etc. - I think this is an absolute default setting from Espo.



            Now I want to create a Report with the advanced pack, selecting entity type "Task" and create a list-report.

            In the Columns, I can now select all fields from "account" - that's ok.
            so if I have tasks on the list, which are not assigned to a account, this positions in the list just stay empty - also ok.

            But, why I cannot select the fields from "contact"?


            From the view of a task, there is no difference, if this task is assigned to an account or to a contact...?
            So I'm pretty sure, it's something somewhere in in the relationship settings, that this works with fields from account, but not from contact and others... but why? what's the logic...?



            At the end I need a simple lists from Tasks (I can filter them perfectly with the report), which are showing on the list fields from the task itself, but also from the related contact (as mentioned, I can do this already, if the task is assigned to an account - I can list the fields from account...).

            Comment


            • #7
              Because there is a hidden relationship between account and task of one-to-many type. If you select account as a parent then this account will be filled.

              Contact is linked only with parent type, as any other possible parent types. But there is no contact-task relationship (like with account).

              Comment


              • #8
                and is it somehow possible, to create this "hidden relationship" between contact and task...?

                as I said, this would be really crucial for us, and for my understanding/view, this is a really basic Report that we want to generate and is something that was confirmed, that it is easly possible with the AdvancedPack...

                Comment


                • #9
                  Yes.

                  1. You need to create relationship contact-task (one-to-many).

                  2. Create file custom/Espo/Custom/Repositories/Task.php.

                  PHP Code:

                  <?php

                  namespace Espo\Custom\Repositories;

                  use 
                  Espo\ORM\Entity;

                  class 
                  Task extends \Espo\Modules\Crm\Repositories\Task
                  {
                      protected function 
                  beforeSave(Entity $entity, array $options = array())
                      {
                          
                  parent::beforeSave($entity$options);

                          
                  $parentId $entity->get('parentId');
                          
                  $parentType $entity->get('parentType');
                          if (
                  $parentId && $parentType) {
                              if (
                  $parentType == 'Contact') {              
                                  
                  $entity->set('contactId'$parentId);
                              }
                          }    
                      }
                  }

                  3. Clear Cache.
                  Last edited by yuri; 02-20-2018, 08:29 PM.

                  Comment


                  • #10
                    ok, sounds great, and immediatly done.

                    Unforuantelly, without success...? Created the file with your content, cleared cache. Even restarted Xampp service.

                    Still can only select fields from account, not from contact...

                    Comment


                    • #11
                      This will work only for new created records.

                      Or you can do fake Mass Update of existing tasks that will run that code.

                      Maybe you didn't create a relationship correcty. Item 1.
                      Last edited by yuri; 02-20-2018, 08:45 PM.

                      Comment


                      • #12
                        Also check the code. I fixed it after posting.

                        P.S. I'm out.

                        Comment


                        • #13
                          ok, have now:
                          - created the Task.php file with your code
                          - cleared the cache (with the option in the backend - right?)
                          - restarted xampp services
                          - created a new task
                          - mass upgraded all existing tasks (changed priority)
                          - created a new report

                          in the dropdown for the colums, there is still nothing from contact

                          Comment


                          • #14
                            ok, re-copied the code, and did all the steps above again - still nothing from contacts showing up under Columns...


                            but already now, a really great thank you for your support and assitance! I really hope, we can get it working somehow...

                            Comment


                            • #15
                              I created relationship and it worked! I could add fields from contact to List report from Task ! Names of links DO MATTER.

                              Please re-check all you did.
                              Click image for larger version  Name:	task.png Views:	1 Size:	24.8 KB ID:	34848

                              Comment

                              Working...
                              X