after:save and after:destroy events

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brianpunzalan
    Active Community Member
    • Aug 2017
    • 62

    after:save and after:destroy events

    Hi Team,

    May I know where can I locate the events after:save and after:destroy?

    Thanks!
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    More details, please. What do you want to do? On the backend or on the frontend?

    Comment

    • brianpunzalan
      Active Community Member
      • Aug 2017
      • 62

      #3
      I was trying to dissect the calendar.js select and eventClick callbacks. I guess both backend and front-end would do.

      Comment


      • brianpunzalan
        brianpunzalan commented
        Editing a comment
        /client/src/views/calendar/calendar.js
    • tanya
      Senior Member
      • Jun 2014
      • 4308

      #4
      For backend you can use hooks https://www.espocrm.com/documentatio...lopment/hooks/
      About frontend - espocrm frontend is based on backbone http://backbonejs.org

      Comment

      • brianpunzalan
        Active Community Member
        • Aug 2017
        • 62

        #5
        The frontend has now been detecting that there is a conflict and halting it from saving the UI model. But, on the backend, my conflicted schedule has still been saved. So therefore, after refreshing the page, it refetch all of the events from the backend and update again the UI model which makes it an issue.

        Should I just use hooks for this scenario? Also, I cannot fully understand the documentation about making my own hook type and how could I triggered it for my specific case.

        Below is a snippet code from calendar.js where I make some modifications to prevent the conflict selection.

        Thanks!

        Code:
        select: function (start, end, allDay) {
                            var dateStart = this.convertTime(start);
                            var dateEnd = this.convertTime(end);
        
                            var attributes = {
                                dateStart: dateStart,
                                dateEnd: dateEnd
                            };
                            if (this.options.userId) {
                                attributes.assignedUserId = this.options.userId;
                                attributes.assignedUserName = this.options.userName || this.options.userId;
                            }
        
                            this.notify('Loading...');
                            this.createView('quickEdit', 'crm:views/calendar/modals/edit', {
                                attributes: attributes,
                                enabledScopeList: this.enabledScopeList,
                                scopeList: this.scopeList
                            }, function (view) {
                                view.render();
                                view.notify(false);
                                this.listenToOnce(view, 'after:save', function (model) {
                                    // custom
                                    if(!this.checkOverlap(start, end)){
                                        this.addModel(model);
                                    }
                                    else{
                                        this.notify("Conflicting schedule. Event has not been created.");
                                        this.removeModel(model);
                                    }
                                    // end custom
        
                                }, this);
                            }, this);

        Comment

        • tanya
          Senior Member
          • Jun 2014
          • 4308

          #6
          If you want to stop saving on backend, you could create beforeSave hook and throw an error http://forum.espocrm.com/forum/devel...-in-beforesave
          I don't know everything you want to implement

          Comment

          Working...