[Advanced Pack] update bottom panels when records are added asynchronously

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maarten
    Member
    • Jun 2020
    • 76

    #1

    [Advanced Pack] update bottom panels when records are added asynchronously

    Hi,

    I have made a flowchart that calls an API, gets a result, creates a record of type Task and then relates this task to a Meeting. The flowchart is activated with a button action in a Workflow for the Meeting entity. When I press the button, the relationship is created and shows directly in a bottom panel of the Meeting Record. This flowchart calls an external API which sometimes takes too long to respond, so I want to make this asynchronous.

    Therefor, I have changed the workflow. When the user presses the button, it now creates a record of type Query (in a flowchart). It relates the query record to the entity record. The API is then called. The API will use the EspoCRM API to update the Query record with the query result. I then have a workflow on entity Query that listens to updates on Query records. When it detects that a Query is updated related to a Meeting record, it executes a formula script. The formula script then creates the Task records and relates them to the Meeting record.

    So both setups create Tasks and relate them to Meeting.

    However the difference is:
    1. The first workflow updates the Tasks in the bottom panel when I trigger the button action (however when the API request times out, it fails to create tasks)
    2. The second workflow doesn't update the Tasks in the bottom panel. I need to refresh the page to see the tasks.

    This is not really great for user experience. Is there a way in the asynchronous setup (2) to also auto refresh the bottom panel when records are related?

    I already have a websocket connection.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 9668

    #2
    Hi,

    Note that refreshing a panel without direct user action usually better to avoid, as the user might work with the exactly the same list at the moment.

    For specific cases, I'd go with a custom code that refreshes the specific panel.

    Triggering this event will force the panel to refresh.

    PHP Code:
    this.model.trigger('update-related:{linkName}'); 
    You can use a custom WebSocket event to let the frontend know when to update. You can submit this WebSocket event either for a custom formula function or from a Hook. Subscribe to the event in the frontend, you can do it in a view setup handler. Unsubscribe, on the view removal (the view's 'remove' event').

    Comment

    Working...