Announcement

Collapse
No announcement yet.

Infield calculation

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

  • #16
    This functionality is just a simple tool to avoid the need to use calculator when one need to do very simple math, e.g. = 100 * 12, where 100 is a monthly price, 12 is the number of months. It does not work like formula in spreadsheets (MS Excel), it's not stored.

    For calculated fields consider using the Formula functionality.

    Comment


    • #17
      Ok, understood. I was looking for a feature to calculate something live on the screen without pressing "Save", for example, I have Price-field and Quantity-field and then Total Cost-field would be calculated inline on-screen, Price*Quantity.

      Comment


      • esforim
        esforim commented
        Editing a comment
        Probably have to use the Sale Packs or Invoice one to get it to work live

    • #18
      You'll need a little bit coding to achieve that. You could use https://docs.espocrm.com/development...etup-handlers/

      Comment


      • esforim
        esforim commented
        Editing a comment
        If you manage to get this to work with yuri referenced link, I would like to see the tutorial too

    • #19
      I suggest using a dynamic handler https://docs.espocrm.com/development/dynamic-handler/

      In our application we have a "CollectionIssue" entity with fields "pastDueRent", "lateFee" and "totalAmountDemanded".

      Here is the code to automatically update the value of totalAmountDemanded when either "pastDueRent" or "lateFee" change:

      Code:
      define('property-management:collection-issue-dynamic-handler', ['dynamic-handler'], function (Dep) {
      
          return Dep.extend({
      
              init: function () {
                  this.controlFields();
      
                  // invoke controlFields method every time pastDueRent or lateFee changes
                  this.recordView.listenTo(
                      this.model, 'change:pastDueRent', this.controlFields.bind(this)
                  );
                  this.recordView.listenTo(
                      this.model, 'change:lateFee', this.controlFields.bind(this)
                  );
      
              },
      
              controlFields: function () {
                  const pastDueRent = this.model.get('pastDueRent');
                  const lateFee = this.model.get('lateFee');
                  const totalDue = pastDueRent+lateFee;
                  this.model.set('totalAmountDemanded',totalDue);
              }​
              
      ​    });
      });​

      Comment


      • DashingUno
        DashingUno commented
        Editing a comment
        Thats an interesting solution, we currently opted in for an API call, but maybe thats a better way to do it.

    • #20
      Dynamic handler is a better option.

      Comment


      • #21
        Here is then another challenge. In user profile I have "Approving Manager" field (related to users entity). Then I have a "Purchase Request" entity and in it's create page, I would need to prepopulate the "Assigned User" field with the user's "Approving Manager". I cannot use workflow as user must be able to change this if his approving manager is on leave.

        Would Dynamic Handler be able to do this and prepopulate fields on page load?

        Comment


        • #22
          I recommend to open a different thread, because: "Here is then another challenge."

          Comment


          • #23
            Since this thread was dug out, I wanted to take a moment to express aprreciation to Yuri for implementing this feature, we use it extensively now.
            Thank you for your work

            Comment

            Working...
            X