How can I run a function when a parent Record View function runs?

I am building a customisation that extends a view (BaseProductBundlesQuoteDataGroupListView) that already extends the BaseRecordView and I need one of my custom functions to run after a new record is saved.

I've found that there are save() and handleSave() functions in BaseRecordView, but I have been unable to extend or _.wrap() them in any way I could find. Running my function on this.context.get('parentModel').on('save') or 'saved' does not work at all. I have also tried runing it on this.parent.context.on('button:save_button:click'), but nothing happens.

Do you know how to do this efficiently without messing around with creating an additional view and duplicating my custom methods?

May I should build this the other way around and extend  the Quotes record view, getting and using the child view of BaseProductBundlesQuoteDataGroupListView?

Parents Reply
  • Hey Francesca Shiekh,

    I guess you are asking me this question because of my answer to this thread:How are record and create views supposed to work? 

    I am linking it so that other users have come context.

    Right this moment (as far as I know) the custom record.js and custom create.js of a module (custom/modules/<modulename>/clients/base/views/create|record/create.js|record.js) do not seem to extend each other directly, down the chain of extension.

    create.js extends record.js controller on all the non-module specific (as in clients/base/views and custom/clients/base/views) controllers.

    The order of extension of non-module specific controllers for creation is:

    • Custom create view
    • Core create view
    • Custom record view
    • Core record view

    In light of that, depending on if there is a core module create and record controller, you might be able to make them derive from each other on a case by case basis. You should be able to do that pretty easily for newly created custom modules.

    Just to double check, please give me few days to confirm the state of things but I think the above should help you get started

    Cheers

    ====================

    Update

    ====================

    After further investigation the above is correct. If functionality needs to be shared between a module's custom create.js and record.js controller, the most appropriate path forward is by leveraging a plugin that is added on both controllers.

    Plugins can be found on clients/base/plugins normally within the specific module, and then it needs to be added within the appropriate view's controller. An example can be 

    modules/KBContents/clients/base/plugins/KBContent.js used in multiple places including the record.js and create.js views controllers

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

Children