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.
Regards,
Deepak
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.
Regards,
Deepak
Hi Deepak Kumar
Which version you are using ??
Hi Mehul Bhandari,
Sugar CRM 7.7.1 version.
Hi Deepak Kumar
create file on below place.
custom/modules/<MODULE NAME>/clients/base/views/create/create.js
({
extendsFrom: 'CreateView',
initialize: function (options) {
this._super('initialize', [options]);
this.context.on('button:save_button:click', this._save_desc, this);
},
_save_desc: function (model) {
console.log("Mehul Bhandari");
},
})
custom/modules/<MODULE NAME>/clients/base/views/record/record.js
({
extendsFrom: 'RecordView',
initialize: function (options) {
this._super('initialize', [options]);
this.context.on('button:save_button:click', this._save_desc, this);
},
_save_desc: function (model) {
console.log("Mehul Bhandari");
},
})
Hope this Helpful to you...
I want to add my functionality to the existing save functionality by doing this.
For example if i put alert in the function like above.
I get the alert first and then the parent save function gets executed.
I want the save to do it work first and then do my functionality which i write in my function
Regards
Sidhu
Hi sidhu sidhu
You can write after_save logic Hook for this..
If you want anything else then let me know.
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
$newActivity->name=$accountBean->name;
$newActivity->date_start=$bean->next_activiti_date_c;
$newActivity->description=$bean->next_activity_desc_c;
$newActivity->save();
$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 ="";
JSON.stringify(this.model,function(key,value){
url=value.new_call_id_c;
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});
if(!_.isEmpty(url))
{
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.render();
}
}, 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);
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);
successCallback();
} else {
console.log("7 "+url);
this._saveModel();
}
}
}, this));
} else if (error.status === 403 || error.status === 404) {
this.alerts.showNoAccessError.call(this);
console.log("8 "+url);
} else {
this.editClicked();
console.log("9 "+url);
}
}, this),
lastModified: this.model.get('date_modified'),
viewed: true
};
options = _.extend({}, options, this.getCustomSaveOptions(options));
this.model.save({}, 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
Regards
Sidhu