AnsweredAssumed Answered

How do I access real-time field values in record.js?

Question asked by Juho Heikkilä on Oct 2, 2015
Latest reply on Oct 5, 2015 by Juho Heikkilä
I'm trying to build a simple character counter for a customer for a text-area field, and having managed to add a keyup event listener I'm now somewhat puzzled by why this.model.get seems to return value from when the record was last saved, rather than the real-time string visible in the UI. 

Customer's record view contains (among other things) a multi-row text-area ('my_field') and a varchar field ('my_field_length') to be used for showing the length of the text written to the first one.

The following javascript extention for custom/modules/ProspectLists/clients/base/views/record/record.js fires the keyup event and calls the handling function. This seems to work just fine.

However, the this.model.get('my_field') in the called function seems to retrieve the saved content of the field, rather than real-time value. In practice, when I write in the box, the number stays static, but when I save the record by pressing the save button, and then write in the box, on first keyup the value shown in the my_field_length updates to the length of the text in the box when it was saved.

    extendsFrom: 'ProspectListsRecordView',
    initialize: function (options) {
        app.view.invokeParent(this, {type: 'view', name: 'record', method: 'initialize', args:[options]});{},,{'keyup.my_field':'set_my_field_length'});     
    set_my_field_length: function(){
      var messlen = this.model.get('my_field').length;

Any ideas how to make it update the value to reflect the current text in the text-area as the text is written?

The test environment has been Sugar Pro