Skip to content

Instantly share code, notes, and snippets.

@elchele
Created January 22, 2016 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elchele/b2a7eba2e96be69f90fc to your computer and use it in GitHub Desktop.
Save elchele/b2a7eba2e96be69f90fc to your computer and use it in GitHub Desktop.
Custom record view controller for displaying an alert upon a record being accessed, if it meets a given criteria.
({
/* File: ./custom/modules/Leads/clients/base/views/record/record.js */
extendsFrom: 'RecordView',
initialize: function(options) {
this._super('initialize', [options]);
this.model.on('data:sync:complete', this.showAlert, this);
},
showAlert: function(){
var currentStatus = this.model.get('status');
if (currentStatus === 'Converted')
{
app.alert.show('ConvertedLead', {
level: 'warning',
title: app.lang.get('LBL_ALERT_TITLE', this.module),
messages: app.lang.get('LBL_ALERT_MESSAGE', this.module),
autoClose: false
});
}
}
})
@elchele
Copy link
Author

elchele commented Jan 22, 2016

The example in this controller will display the Alert if Status equals Converted on the selected Lead record. Note that it requires the definition of the labels LBL_ALERT_TITLE and LBL_ALERT_MESSAGE in the module's language file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment