Redirect to a record view  in php-logichook

Hi All,

                How can we redirect to the record view of another record(sidecar) using the after save logichook(php)

Regards André Lopes Francesca Shiekh hats

Sidhu

Parents Reply Children
  • Hi André Lopes

                       This is what i have tried but i am unable to redirect in the success call back.

    How can i override save button call? 

    Regards

    Sidhu

  • Hi,

                 I have tried in the record.js in the saveModel function

       _saveModel: function() {
            var options,
                successCallback = _.bind(function() {
                        
                        alert("successcallback");
                        var test="";
                        //console.log(JSON.stringify(this.model));
                        JSON.stringify(this.model,function(key,value){
                             
                             console.log("key "+key);
                             console.log("value "+value);
                             console.log("value "+value.new_call_id_c);
                             test=value.new_call_id_c;
                             console.log("test "+test);
                             });
                    // 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("test if "+test);
                        }
                        console.log("test if "+test);
                    });
                   
                    App.router.navigate(test, {trigger: true});//this is asking confirmation
            
                    if (this.createMode) {
                        app.navigate(this.context, this.model);
                        console.log("if createMode");
                    } else if (!this.disposed && !app.acl.hasAccessToModel('edit', this.model)) {
                        //re-render the view if the user does not have edit access after save.
                        this.render();
                        console.log("else createMode");
                    }
                }, this);

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

            options = {
                showAlerts: true,
                success: successCallback,
                error: _.bind(function(error) {
                    if (error.status === 412 && !error.request.metadataRetry) {
                        this.handleMetadataSyncError(error);
                    } else if (error.status === 409) {
                        app.utils.resolve409Conflict(error, this.model, _.bind(function(model, isDatabaseData) {
                            if (model) {
                                if (isDatabaseData) {
                                    successCallback();
                                } else {
                                    this._saveModel();
                                }
                            }
                        }, this));
                    } else if (error.status === 403 || error.status === 404) {
                        this.alerts.showNoAccessError.call(this);
                    } else {
                        this.editClicked();
                    }
                }, this),
                lastModified: this.model.get('date_modified'),
                viewed: true
            };

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

            this.model.save({}, options);
        },

    You can see the code at line number 26.

    It is asking confirmation like - "There are some unsaved changes do you want to continue" i dont want this confirmation while i am navigatign.

    Can you please update what is the best i can do to prevent this confirmation and redirect to the new record.

    I am storing the new record value in a field called new_call_id_c via a logichook and in the save model function i am using it to redirect.

    Regards

    Sidhu

  • You need to override the method 'hasUnsavedChanges' and make it returns false on specific conditions (when it should redirect to some other record view).

    Cheers

    André Lopes
    Lampada Global
    Skype: andre.lampada