How can we Repair and Rebuild when creating a record through a custom hook file after save functionality? Note:- It saves records when we need them not regularly.

Hello all,

I'm wondering if there is a way to trigger Repair and Rebuild automatically when creating records via hooks after saving. I have a custom module where I create records, and I'm currently updating the JS file manually after creating each record to trigger Repair and Rebuild. Rather than having to go through the admin section to trigger Repair and Rebuild each time, I'd like to automatically run Repair and Rebuild as part of the record creation process.

Does anyone know if it's possible to automatically trigger Repair and Rebuild from a hook after saving a new record? Any pointers on how I could implement this would be greatly appreciated!

Thank you!

Parents
  • Hi  ,

    The repair & rebuild process is not something I recommend attaching to record creation. This process is highly destructive and can potentially cause corrupted cache files (i.e. system down problems requiring a manual clearing of cache files at the server level) when it runs during user activity. For these reasons, we recommend to all our clients to only perform processes that trigger repair and rebuild (e.g. module/plugin deployments, Studio updates, etc.) during maintenance windows where user activity is non-existent or at a minimum. 

    Why are you seeking to rebuild cache every time a new record is created in your hook?

    Chris

  • Hi ,

    Manual repair and rebuilding while creating records is not something I want to do. Instead, I create a JS file. My goal is for the hook to be on after save functionality, and records in that module are not being created every time, as if they're only created once in a while.

  •  Hi  ,

    Your JS would probably have some sort of hardcoded values based on this record creation right? You should make it dynamic and extract that data through our API endpoints just like the whole Sugar codebase, that's the way to go, running QRR is not.

    You modify your JS file to make an AJAX call to the server and pull out all the data you need like so:

    var url = app.api.buildURL('Accounts/' + <ANY FILTER>, null, null);
    app.api.call('read', url, null, {
        success: _.bind(this.myMethodThatPopulatesDropdownValues, this),
        error: function() {
            app.logger.error('Something bad happend, gotta retry');
        }
    });

    SugarCRM | Principal Developer Advocate

  • Hi ,

    Please help me with one issue I am facing right now. I want to customize the specific fields. As for a home phone, I created a JS file in the path.

    custom/modules/Leads/clients/base/fields/home_phone/home_phone.js


    I want to do some customization on that field so that it doesn't affect the other phone-related fields if I create a phone.js then it is working but when I create home_phone.js it doesn't and also I don't want to do it from the record.js file as well.

    Can you help me out of this?

Reply
  • Hi ,

    Please help me with one issue I am facing right now. I want to customize the specific fields. As for a home phone, I created a JS file in the path.

    custom/modules/Leads/clients/base/fields/home_phone/home_phone.js


    I want to do some customization on that field so that it doesn't affect the other phone-related fields if I create a phone.js then it is working but when I create home_phone.js it doesn't and also I don't want to do it from the record.js file as well.

    Can you help me out of this?

Children