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

Reply
  •  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

Children