Announcement

Collapse
No announcement yet.

notification after changes in subpanels

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

  • notification after changes in subpanels

    Hi.

    I created an entity name "Member" and a sub-entity named "Options" that I'm showing as a subpanel of "Member" entity, then the Member have a field that needs to be updated every time new "Options" are added or removed from the subpanel (but the value to update on member is VERY complex to calculate, in fact needs to call a 3rd party API with all options to obtain the value that needs to go inside the "Member".

    I have done a LOT research, with views, def (in JSON), js-scripts for all views list / detail / edit, trying to customize the subpanels actions (remove, add) .. but I can't find how to do that. Can anyone give me a clue ?

  • #2
    Hi jugama,

    You can try to create two Workflows with the Signal Trigger Type (one with a @relate signal, one with a @unrelate signal):
    https://docs.espocrm.com/administrat...als/#default_1,
    https://docs.espocrm.com/administrat...kflows/#signal.

    After you add an Option to a Member or remove it, Workflows will trigger and update the desired field of the Member record with some actions (you may need Execute Formula Script and Send HTTP Request actions in this case): https://docs.espocrm.com/administrat...flows/#actions.

    These two Workflows can be combined into a BPM for convenience: https://docs.espocrm.com/administration/bpm.
    In BPM you can also add two Signal Start Events and do the same thing:​ https://docs.espocrm.com/administrat...al-start-event.

    Please note that Workflows and BPMs are Advanced Pack extension features.

    Comment


    • #3
      Hi, thanks for you promptly answer !.

      Well, I was trying to find a solution without any of the advance packages extensions. So, if there is any EVENT I can attach to from here ..
      ​------------------------------------------------------------------------
      define('custom:views/member/detail', 'views/detail', function (Dep) { //*** member detail view (main entity) .. options is the list on the bottom ..
      return Dep.extend({
      setup: function() {
      Dep.prototype.setup.call(this);
      .... attach .. to event .. ( call-me back )
      ​------------------------------------------------------------------------
      Will be great to attach an event or something that notifies me if the option list within the bottom sub-panel has changed. So I can call using jquery the 3rd party API providing the values within the sub-panel list, get the value and then updating the member accordingly.

      Am I on the right forum channel or so ?

      ​------------------------------------------------------------------------
      ​simple:
      Member Name: Jhon Doe
      Member PFH-Value: PF2-DELD ~ OPT-PF12

      sub-panel (options)
      PF2 7.234 54.342
      PF12 9.470 8.273

      Comment


      • #4
        who will be notified ? assignedUser of Member record or .. ?
        Why not use for your sub-panel (options):





        it's really simple :
        in hook of Options : afterSave ... just create a Job with Data id of Member.

        And this Job make your call to 3 party.

        Maybe a solution for you

        Comment


        • #5
          Hi,

          That's a very good solution, but what about the UI info ? .. I need the field "Member PFH-Value" populated in the UI. .. think like an invoice system for example .. every time you add items .. the total gets updated ... ( that's very similar to what I need ) .. the only difference is that the total is calculated on the UI without the need of sending data to the backend (only visually) .. .. the only difference here is that .. every time a new row is created on the sub-panel .. ( the field in the Member needs to be updated visually ) .. and of-course in the back-end too.

          With that hook solution .. I can do the API calls on the back-end .. (but it's a free public API, so it's better to be run from the end-user instead of from the back-end) .. but the problem in the UI is still there .. ex: .. adding a row in the subpanel (the hook gets triggered) .. then updates happen in the back-end .. but I need something to notify me (the row addition to the sub-panel) .. so I can do a model.fecth() .. in order to bring the new value on the member entity and display it. ..

          so, I need the UI updated too. ... any comments ?

          Comment


          • item
            item commented
            Editing a comment
            I have a job who do something like you will.
            if websocket, the field is updated in front-end.. Job save "Member" entity.

            and i have a notification send to assignedUser of "Member" (see a recent post of Rabii : search notification in forum)

          • jugama
            jugama commented
            Editing a comment
            THANK YOU so much .. I'm not that smart .. and I was not able to find anything .. .. BUT .. THANK YOU .. for your time !!! .. a LOT
        Working...
        X