Refresh/Recalculate Formula after linking Relationship

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esforim
    Active Community Member
    • Jan 2020
    • 2220

    #1

    Refresh/Recalculate Formula after linking Relationship

    Now that I'm using formula more I noticed this issue, or maybe my formula is bad.

    But when you link a Relationship through bottom panels, the formula doesn't get run again. Anyone know can I can re-run it again after I create a new relationship?

    I was thinking of using the "Modified Date" to do that but linking/creating relationship doesn't change this date.

    Thank you.

    Screenshot for a better picture:
    Click image for larger version

Name:	image.png
Views:	474
Size:	23.5 KB
ID:	91659
    So this entity I have formula to sum all Credit and sum all Debit. When I link it or create a new Record using the + button, the formula don't run.

    I need to make some edit in the Case entity itself.
  • lazovic
    Super Moderator
    • Jan 2022
    • 1208

    #2
    Hi esforim,

    Please tell me if I understand correctly that you need to add to the total amount of Debit and Credit in the Case the values of the Debit and Credit of Accounting when you link it to this Case?

    Comment

    • esforim
      Active Community Member
      • Jan 2020
      • 2220

      #3
      Originally posted by lazovic
      Hi esforim,

      Please tell me if I understand correctly that you need to add to the total amount of Debit and Credit in the Case the values of the Debit and Credit of Accounting when you link it to this Case?
      Hi lazovic, I can already calculate it using these formula. But formula doesn't run when I just link it.

      It only run when I made edit to the Case entity. So the question is, how to make Formula "re-run" after I link.

      Comment

      • telecastg
        Active Community Member
        • Jun 2018
        • 907

        #4
        Hello esforim

        Formula is a custom EspoCRM language, which allows GUI Users to write beforeSave hooks, without actually coding in PHP.

        A beforeSave hook, is a backend function that is executed after the system receives a "Save" command but before the data is actually persisted into the database.

        The actual result is that a formula will not execute until you save the entity that contains the formula.

        If your formula is attached to the "Case" entity, then it will run when the case entity is saved.

        If your formula is attached to the "Accounting" entity, it will run when the Accounting record is saved.

        There is no GUI method at present to run formulas at will.

        To do that you will need to do some coding https://forum.espocrm.com/forum/gene...4301#post64301

        or you can purchase an extension which will create a formula re-calculate button for you https://payhip.com/b/28Dhw

        Comment


        • esforim
          esforim commented
          Editing a comment
          Hi telecastg! Thank you. That too bad, look like it can't be done (easily).

          I couldn't get this out of my head and I think and think. *Light bulb* moment and I thought. "Not why create a Formula in "Accounting" that does an update to the "Case" entity"?

          Wouldn't that forced the Case's Formula to run?! This is a excited theory that I hope to work.... I will eventually get around to trying it.

          Right now I'm playing with even more formula to automatic link my Email > Case correctly. It looking good so far as a very simple formula is expand to hard to read mode for me.

          Hopefully once I'm happy with it covering and 'no more bug' I will post it at the usual place.

          Thank you again. By the way, I think Yuri recently added some "beforeSAVE" code in Git, but then he say, "This is for developer only" so it out of my hand till easy version come along.
      • abhilash.kumar.niit
        Senior Member
        • Sep 2024
        • 132

        #5
        Hi @esforim ,

        just want to ask did you get any solution of your problem? as i am also facing the same issue.

        Comment


        • esforim
          esforim commented
          Editing a comment
          Hi, unfortunately I been very slacking on running EspoCRM on life support style. Didn't even update to latest version yet.

          That said, I don't have a solution yet. I went back to Excel/Spreadsheet for these calculation for now.
      • crmclients
        Senior Member
        • Jul 2020
        • 316

        #6
        Looking for this too, ability to create a button on a Lead/Other record would be great
        Currently have the Meeting status updating the Lead status but only after going to Lead list view and doing a Recalculate then going back into the Lead to finish up

        Comment

        • shalmaxb
          Senior Member
          • Mar 2015
          • 1837

          #7
          Few years ago the fellow member of this forum telecastg published an extension, which creates a button in any assigned entity to do the recalculation and refrehing the browser view. He published it in the beginning for free, later you had to purchase the extension. Unfortunately telecastg suddenly vanished from this forum and the sales platform got also closed.
          As I am not authorized to provide this extension publicly, I will see, if I can program something similar. One reason for that would be the fact, that the extension from telecastg will be outdated some day, as it had been published in 2021/2022 (still version 7.x that time).
          As soon as I have something, I will publish here in the forum.

          Comment


          • crmclients
            crmclients commented
            Editing a comment
            thanks so much shalmaxb, I found the links researching and got 404 each time, I appreciate you closing that gap, I was wondering what happened; telecastg was very helpful and industrious.

            FYI my client is using the Cloud version so not sure if they will move up to Enterprise anytime soon which allows for extensions but I am sure it will be useful for others who can use it now.

            Meanwhile, the Lead status seems to be updating on Save when coming back from the Meeting record and the client is presently happy so whew!

            That said, I look forward to your update as the are piling on more conditions and EspoCRM is meeting the challenge!
        • Dvd
          Junior Member
          • Feb 2026
          • 1

          #8
          I want to use this function entitysumRelated(LINK, FIELD, FILTER) inside workflow actions. I have entity A with a duration field that I want to sum into entity B's totalDuration field. I have a many-to-one link. I tried updating it through the workflow and it works, but when I put sumRelated, etc., it stops updating the field.

          Comment

          Working...