Hi does anyone know if it is possible to add additional custom keyboard shortcuts in the same manner Sugars standard ones? It would be very use full.
Hi does anyone know if it is possible to add additional custom keyboard shortcuts in the same manner Sugars standard ones? It would be very use full.
Hi Gustav Lindstrom,
I will explain,how it can be done custom short cut keys .
Step 1:
Create file record.js in below path
custom/modules/{module-name}/clients/base/layouts/record/record.js
ex.
custom/modules/Accounts/clients/base/layouts/record/record.js
Then copy content from
clients/base/layouts/record/record.js
and paste it to this file.
Then add our shortcut name at end of this file ( bold values are our shortcut key name)
custom/modules/Accounts/clients/base/layouts/record/record.js
({plugins:['ShortcutSession'],shortcuts:['Sidebar:Toggle','Record:Edit','Record:Delete','Record:Save','Record:Cancel','Record:Previous','Record:Next','Record:Favorite','Record:Follow','Record:Copy','Record:Action:More','Record:Test']})
Then save this file
Step 2:
custom/module/{module-name}/clients/base/views/record/record.js
ex
custom/modules/Accounts/clients/base/views/record/record.js
In this file
override registerShortcuts() function and add our functionality for shortcut key.
Example:
Here i am trying click flow button by shortcut key ( f and ctrl+alt+f).
Here is the file
({
extendsFrom:'RecordView',
initialize:function(options){
this._super('initialize',[options]);
this.events=_.extend({},this.events,{
'click a[name=test_button]':'_testAlert',
});
},
_testAlert:function(){
app.alert.show('Validate', {
level : 'info',
messages : 'SugarCRM info message',
autoClose : false,
});
},
registerShortcuts: function() {
app.shortcuts.register('Record:Test', ['t', 'ctrl+alt+t'], function() { //here Record:Test
this.$('.headerpane [data-toggle=dropdown]:visible').click().blur();
this.$('.headerpane [name=test_button]:visible').click(); //clicking the button
}, this);
this._super('registerShortcuts'); //calling super function
},
})
From above example
Record:Test - name of shortcut key and view ( this should match with which we added in layout/record.js)
't', 'ctrl+alt+t' - shortcut key
name=test_button - this is my button.Note my button will come in more action in record view.
Done.
Then make quick repair and rebuild.Done
Have a look at Creating custom keyboard shortcuts in sugarcrm
Thanks!.