How can i override save button call?

Hi Team,

How can i override save button call. I want to right some logic at client side on click of save button.

What is the correct way of doing it.



Parents Reply Children
  • Hi Mehul  Bhandari

                                 Here is my scenario.

    I am creating a new call record using a before save logichook in the calls module.

    i am saving the new record id and its module in a field called new_call_id_c.

    The logichook code-this is in the calls module and i am creating a new call on saving the call with status held.

    class newActivity
         function newActivity($bean, $event, $arguments)

    if($bean->create_new_activity_c == 0 &&  $bean->parent_type == "Projects" && ($bean->status=="Held" || $bean->status=="Complete"))
                        $projectBean = BeanFactory::getBean("Projects",$bean->parent_id , array('disable_row_level_security' => true));//get account bean
                   if($projectBean->status_c != 'Completed' && $projectBean->status_c != 'Cancelled' && $projectBean->status_c != 'No_prospects' )
                           $accountBean = BeanFactory::getBean("Accounts",$bean->account_id_c , array('disable_row_level_security' => true));//get account bean
                           $newActivity = BeanFactory::newBean($bean->next_activity_type_c);//create new activity bean
                           $bean->new_call_id_c=$bean->next_activity_type_c.'/'.$newActivity->id.'/edit';//here i am saving the new record edit view
                           $bean->create_new_activity_c=1;//changing it to one so that the logichook doesnt execute  //  multiple times

    Now after saving the record i want to navigate to the new record that i have created in the logichook i.e.the value stored in the new_call_id_c field.I have tried in the logichook but with no success.

    I have done this in the create.js.But facing issues in the record.js file.

    So in the custom record.js file of the Calls module i have copied the parent _saveModel function.

          _saveModel: function() {
              var url ="";
              console.log("1 "+url);
            var options,
                successCallback = _.bind(function() {
                    // Loop through the visible subpanels and have them sync. This is to update any related
                    // fields to the record that may have been changed on the server on save.
                    _.each(this.context.children, function(child) {
                        if (child.get('isSubpanel') && !child.get('hidden')) {
                            child.get('collapsed') ? child.resetLoadFlag(false) : child.reloadData({recursive: false});
                                       console.log("2 "+url);
                                       App.router.navigate(url, {trigger: true});
                    if (this.createMode) {
                             console.log("3 "+url);
                        app.navigate(this.context, this.model);
                    } else if (!this.disposed && !app.acl.hasAccessToModel('edit', this.model)) {
                        //re-render the view if the user does not have edit access after save.
                        console.log("4 "+url);
                }, this);

            //Call editable to turn off key and mouse events before fields are disposed (SP-1873)

            options = {
                showAlerts: true,
                success: successCallback,
                error: _.bind(function(error) {
                    if (error.status === 412 && !error.request.metadataRetry) {
                        console.log("5 "+url);
                    } else if (error.status === 409) {
                        app.utils.resolve409Conflict(error, this.model, _.bind(function(model, isDatabaseData) {
                            if (model) {
                                if (isDatabaseData) {
                                             console.log("6 "+url);
                                } else {
                                             console.log("7 "+url);
                        }, this));
                    } else if (error.status === 403 || error.status === 404) {
                         console.log("8 "+url);
                    } else {
                        console.log("9 "+url);
                }, this),
                lastModified: this.model.get('date_modified'),
                viewed: true

            options = _.extend({}, options, this.getCustomSaveOptions(options));

  {}, options);

    I have tried in the successCallBack function but i am unable to get the new_call_id_c value in the callback function to navigate to it.

    Even if i am intermittently i am getting a confirmation like ''are you sure you want to navigate there are unsaved changes'

    Where can i do this.So that i will navigate after saving the record.

    So basicallly i want to navigate to the new record that i have created in the logichook,when the call status is Held.

    I have done this in the create.js file

    but facing issues in the record.js file

    André Lopes Francesca Shiekh Tevfik Tümer Angel Magana