Help with creating report

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dnaoverride
    Junior Member
    • Nov 2023
    • 22

    Help with creating report

    Can someone help me create report from 3 entities
    • Contact
    • Contact Categories - which contains category name and required number of visits
    • Meeting

    I need to create report that prints name, required number of visits, actual visits that sales person is made.

    I have tried using joint reports but without any luck.... I'm having problems connecting contact and contact categories entities...
    Tried with formulas when change contact category:
    Code:
    ifThen(entity\isAttributeChanged('contactsCategories'),
        $contact_id = id;
        util\logDebug('XXX',$contact_id);
        $category_id = record\findOne('contact_contacts_category', '', '', 'contact_id', $contact_id);
        $number_of_visits = record\attribute('contactsCategories', $category_id, 'required_number_of_visits');
        entity\setAttribute('Numberofvisits', $number_of_visits);
    );​
    I even installed LogDebug Custom Formula extension for debugging purposes, set 'level' => 'DEBUG' in config-internal.php, but nothing is even printed out in log files.
    Also tried many to many, one to many contact to contact category, all without any luck.

    Any pointers create this report / create appropriate formula. Thanks in advance.
  • dnaoverride
    Junior Member
    • Nov 2023
    • 22

    #2
    It seems no one can help me with this problem, can someone at least point me am I at right track how to aquire data from another entity?

    Thanks

    Comment

    • rabii
      Active Community Member
      • Jun 2016
      • 1260

      #3
      you have not provide any info for someone to help. what is the relationship between the 3 entities ? also see my comments on your code below

      PHP Code:
      ifThen(entity\isAttributeChanged('contactsCategories'),
         $contact_id = id;
         // This logDebug is not supported and i am not sure where did you get this, it will never work. the log is under data/logs
         util\logDebug('XXX',$contact_id);
         // never use '' you should use null instead and also name of the entity should be correct as ContactCategory you need to verify name under administration > entity  $category_id = record\findOne('ContactCategory', null, mull, 'contact_id', $contact_id);
         $category_id = record\findOne('contact_contacts_category', '', '', 'contact_id', $contact_id);
      // this is also wrong fields should be spilted camelCase requiredNumberOfVisits
      $number_of_visits = record\attribute('ContactCategory', $category_id, 'required_number_of_visits');
      entity\setAttribute('Numberofvisits', $number_of_visits);
      );​​ 
      
      Rabii
      Web Dev

      Comment

      • dnaoverride
        Junior Member
        • Nov 2023
        • 22

        #4
        Thanks for reply, I thought I should reference mysql table names, therefore I used them, the '' usage I did see in this forum ?. I will try to modify my code, by your instructions. Cheers ?

        Comment

        • dnaoverride
          Junior Member
          • Nov 2023
          • 22

          #5
          Guys im having a problem in my formula to register if attribute changed... heres the code
          Code:
          if (entity\isAttributeChanged('contactsCategories')) {
              $contact_id = id;
              description = $contact_id;
          }
          ​
          Tried to store something in description for debugging purpose but nothing happends.

          My Contact entity relations attached as image.

          Click image for larger version

Name:	chrome_IpBxcUATrb.png
Views:	243
Size:	106.5 KB
ID:	100839

          Looks like entity\isAttributeChanged('contactsCategories') isn't registering attribute change, anyone got an idea what im doing wrong?
          Attached Files

          Comment

          • rabii
            Active Community Member
            • Jun 2016
            • 1260

            #6
            Try this

            PHP Code:
            if (entity\isAttributeChanged('contactsCategoriesIds')) {
               $contact_id = id;
               description = $contact_id;
            }

            Also you need to have Link Multiple Field enabled on your relationship otherwise it won't work.
            Rabii
            Web Dev

            Comment


            • dnaoverride
              dnaoverride commented
              Editing a comment
              Thanks rabii it works with suggested change....
          Working...