Announcement

Collapse
No announcement yet.

(Re-)calculate/(Re-)run single formula in action of a list view

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

  • (Re-)calculate/(Re-)run single formula in action of a list view

    In the action-menue you are able to delete, merge, mass updates, exports, PDF-prints and re-calculate formulars -> that affects to ALL formulars from entity-manager/formular
    It would be nice to have the possibility to run a (single) (temp) formula given in a script-box

    Christoph
    Last edited by ctheuring; 02-27-2024, 03:20 PM.

  • #2
    You can utilize the formula sandbox for this purpose.

    I don't think we need the feature in Espo. For a one-off use, one can utilize workflows.
    Last edited by yuri; 02-27-2024, 03:21 PM.

    Comment


    • #3
      I suppose for this you could use before save API formula script in the entity manager.

      My idea is:
      1. Create non storable field - bool
      2. Add before save formula script and make a condition if attribute changed do....
      3. Select items and using mass update, update the field you have created in step 1

      This should run your formula script, alternatively if it does not work properly you may need to make the field storable and make the condition in formula script based on if the field is true/false and then at the end of the script (inside the if statement) set it to false.

      Formula sandbox is not ideal because it runs only in the context of single entity.

      Scheduled workflows would work but it's much more overhead - create report, it would probably result in creating additional fields.

      Manual workflows are again in scope of one entity.

      Comment


      • #4
        Hello Yuri,

        Originally posted by yuri View Post
        You can utilize the formula sandbox for this purpose.

        I don't think we need the feature in Espo. For a one-off use, one can utilize workflows.
        That's right ... but it's much more effort to create a workflow for every entity if need to run i.e. different updates for many entities - again and again.
        My goal is: to have a possibility in the action-menu (so it affects ALL entities) to run ONE (or may be more) formula(s) like one of these ones in the formular-box of every entity.
        The current possibility is to execute ALL formulas of the formular-box of the entity - not only one of them or a new one only for this case.

        It would be nice to have such a possibility- but I don't know how much work it is for you. Perhaps put it on the nice-to-have-list :-)

        Christoph

        Comment


        • #5
          Adding features are not always good for a product, it's often better not to have a feature.

          How often are you going to run formula? If it's only for one-off cases, to fix some data, workflows are OK.

          If we add such a feature, I'm sure many people will break their data by running a not well tested script. This will cause our support a headache.

          Comment


          • #6
            Originally posted by ctheuring View Post
            Hello Yuri,



            That's right ... but it's much more effort to create a workflow for every entity if need to run i.e. different updates for many entities - again and again.
            My goal is: to have a possibility in the action-menu (so it affects ALL entities) to run ONE (or may be more) formula(s) like one of these ones in the formular-box of every entity.
            The current possibility is to execute ALL formulas of the formular-box of the entity - not only one of them or a new one only for this case.

            It would be nice to have such a possibility- but I don't know how much work it is for you. Perhaps put it on the nice-to-have-list :-)

            Christoph
            Additional approach comes to mind, while this is not officially documented/supported you could create a varchar field, then modify it's entityDefs type to "formula" and adjust max length to reasonable amount of characters.

            Then you can add this field as available in mass update.

            Make afterSave hook that checks the formula field (has it changed- is it empty?) and if it passes the conditions make it run the formula using formula runner (check how formula sandbox works for code sample).

            Then once formula is done you can simply set the field to null at the end of the hook.

            Just be aware that this solution is bit more hacky and I am 99% sure that using the "formula" field type like this is not it's intention. However it can work and I have built couple modules on this approach (mostly to configure some math expressions, most notably the ones that can change quite often - ex. P&L calculation).

            And while I have no say in espocrm future development I kinda agree with Yuri that this feature is not exactly something Espo needs now. Perhaps adjustment to formula sandbox to add ability to run for multiple entities at once would be more fitting.

            Comment


            • #7
              Hello yuri,

              Originally posted by yuri View Post
              Adding features are not always good for a product, it's often better not to have a feature.

              How often are you going to run formula? If it's only for one-off cases, to fix some data, workflows are OK.

              If we add such a feature, I'm sure many people will break their data by running a not well tested script. This will cause our support a headache.
              I think your reservations are valid ... and security always over comfort.
              Thanks for your statment.

              Christoph

              Comment

              Working...
              X