Announcement

Collapse
No announcement yet.

New numeric field value sum and total value

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

  • New numeric field value sum and total value

    Good morning everyone,

    I need to create a field under the Tasks Entity (possibly under others Entities) with a numeric value (manually inserted by the client)

    Then each value for each task will be summed up to another field located in the Entity Tasks or in other Entity using another numeric field (total)

    I have seen the option Entity Formula but don´t understand very well how it´s work and if it can be done using the Formula facility.

    Hope you can help me,

    Nunos.


  • #2
    Hi,
    as I understand you, you want to sum field value of children records and store it to parent field?

    with formula you can set fields only for this target record (is saving now), not for related.

    You can update related records only with Workflow (and BPM, but you don't need it for this).
    Or you can develop a hook (this way is the best, because you can catch any action https://www.espocrm.com/documentatio...lopment/hooks/ https://www.espocrm.com/documentation/development/orm/)

    Comment


    • #3
      Hi tanya,

      Basically i want to create a simple new Entity for services payments, the client will insert the price value per service and then i want to display the total price of all the services done. a SUM of the price of all the services from that client.

      The total price field will be auto updated as client will create more services and prices.

      Sorry for my question but as i am new to EspoCrm not sure what is the best way to do it.

      Can this be done easily?

      The reporting tool seems to be very powerful in that case. It would be something very similar to the Monthly Revenue report on the Advanced Pack Demo.

      Thanks,

      Nunos.

      Comment


      • #4
        Check Products And Items panel in Quotes on the demo as well.

        If you don't want to use Advanced pack, but make this calculation, I can recommend you only hooks

        Comment


        • #5
          Thank you tanya for your reply,

          Can you show me a couple of examples on how to use Hooks? Simple examples if possible

          The advanced pack is also a way to go as i can see that it is very flexible in terms of report creation as my client will need to probably create different reports in the future.

          Nunos.

          Comment


          • #6

            I'm seeing some unusual behavior when using a beforeSave in a hook for meetings. All is working as expected when users create a meeting from the meeting

            I want to make a Hook to handle "afterSave" event for getting the attached "Worklogs" entity [as comments] attached to another

            Comment


            • #7
              Thank you tanya,

              I am going to check the links,

              Just one more question on this to be sure, can i create any kind of basic operations (+ - / %) with hooks? For example Field C = Field A - Field B (a basic spreadsheet calculation)

              Nunos.

              Comment


              • #8
                you can get the value of entity field and set to another


                $c = $entity->get('fieldA') - $entity->get('fieldB');
                $entity->set('fieldC', $c);

                Comment


                • #9
                  Hi tanya,

                  Thank you for your reply,

                  Have have been able to create a basic formula under one entity using very basic syntax operation between two fields:

                  ataorcamvalorsaldo = ataorcamvalor - ataorcamvalorrea;
                  ataorcamvalorsaldotCurrency = 'EUR';

                  I would like now to do the same now but using fields in different entities.

                  How should i do?

                  Thanks,

                  NunoS.

                  Comment


                  • #10
                    in formula you can get fields from parent entity or other related entity, if could have only 1 related entity (many-to-one relationship).
                    But you can't get data from children entities or if this entity can have multiple entities in this relation (one-to-many or many-to-many)
                    And you can't set fields in other entity (parent, etc). Only in target entity.

                    Comment


                    • #11
                      Hi tanya,

                      Ok, i am going to play around with it, thanks for the support!

                      Nunos.

                      Comment

                      Working...
                      X