I have a flag on Accounts for Partnerships and want to show a custom badge near the name of the record, in a similar way to Converted Leads.
I was able to get this done in a very roundabout way, which I am pretty sure is not the right way... so I am wondering what the right way is.
This is what I did:
created a non-db field in the Accounts vardef
$dictionary['Account']['fields']['warning_c']=array( 'name' => 'warning_c', 'vname' => 'LBL_WARNING_C', 'type' => 'badge', 'len' => '1', 'source' => 'non-db', );
added the non-db badge field to the record view on account
4 => array ( 'name' => 'warning_c', 'type' => 'badge', 'readonly' => 'true', 'dismiss_label' => true, ),
extended the record view to set the field based on the partnerships flag both on change and when the field values are retrieved for display.
extendsFrom: 'RecordView', initialize: function(options){ this._super('initialize', [options]); this.model.on('change:pg_is_partnership_c', this.checkWarning, this); this.model.once('sync', function() { this.checkWarning(); }, this); }, checkWarning: function(){ //handle warning badge conditions //note that warning_c is a non-db field defined in the vardef extension this.model.set('warning_c', 0); if(this.model.get('pg_is_partnership_c')){ this.model.set('warning_c', 1); } }, ...
This works fine when loading the record, and when setting/unsetting the flag I can see the badge appear/disappear.
But when setting the badge, after the save is complete, the badge disappears and only comes back if I reload the record.
I tried a few things like re-rendering after the save is complete, reloading the model etc... but to no avail, and the more I try to get around this, the more I'm convinced it's not the right way to do this...
Can anyone shed some light on how badges actually work?
Thanks,
FrancescaS