How to call save method in Recordlist Js ?

Hi There,

I am looking to trigger alert box confirmation box on onchange and update one of the dropdown field while record edit and save inline (in record list view)

I tried 'handleSave: function() of record js in recordlist js but it't not working.  Please suggest me any way to achive this. 

If we can not use save method in recordlist js then please suggest a way to use onchange event for relate field in recordlist js as onchange event also not working for relate field.

'

Parents
  • Custom validation is not working in recordlist js . although i am able to show the alert box on save button click but default save method is triggering before alert box show , How can we disable default save method in record js ?

  • You need to override method addActions in the js controller of RecordListView in order to set a custom field type for button inline-save. After that you need to create that custom field type extending from EditablelistbuttonField and, at last, override method saveClicked in that js controller.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • ({
        extendsFrom: 'RecordlistView',
    
        initialize: function(options){
           console.log('This is Quotes RecordlistView');
            this._super('initialize', [options]);
        },
    events: {
        'mousedown [name=inline-save]': 'saveClicked',
        'mousedown [name=inline-cancel]': 'cancelClicked'
    },
    saveClicked: function(evt) { 
        var model = App.controller.context.get('model');            
        var rowid = model.get('id');
        var allocated_work_product_c = model.get('allocated_work_product_c');      
        
        var TS_API = "rest/v10/ANML_Animals/" + rowid + "?fields=allocated_work_product_c";        
            App.api.call("get", TS_API, null, {
                    success: function(TSData) {
                        var old_allocated_WP_value = TSData.allocated_work_product_c;
                        console.log('TS_API data : ', TSData);
                        console.log('TS_API data : allocated_work_product_c : ', old_allocated_WP_value); 
                                   
                    if (old_allocated_WP_value != allocated_work_product_c && allocated_work_product_c!='' ) {
                   
                      app.alert.show('Allocated_WP_check_pop_up', {
                          level: 'confirmation',
                          messages: 'These animals are already allocated, are you sure you want to re-assign?',
                          autoClose: false,
                          confirm: {
                              label: "Yes"
                          },
                          cancel: {
                              label: "No"
                          },
                          onCancel: function() {
                             return;
                          },
                          onConfirm: function() {                     
                             model.save();                        
                          }
                      });
                  } else {
                      setTimeout(function() {
                        model.save();
                     }, 2000);
                     
                      //this._super('saveClicked', [evt]);
                  }
                    }
             });
      
                
    },
    })      

    I am using the same , Alert box is working but the issue is that default save method called before the aler box populate. I want to use the save option only on onconfirm click , How can we disable auto save for this function ?

Reply
  • ({
        extendsFrom: 'RecordlistView',
    
        initialize: function(options){
           console.log('This is Quotes RecordlistView');
            this._super('initialize', [options]);
        },
    events: {
        'mousedown [name=inline-save]': 'saveClicked',
        'mousedown [name=inline-cancel]': 'cancelClicked'
    },
    saveClicked: function(evt) { 
        var model = App.controller.context.get('model');            
        var rowid = model.get('id');
        var allocated_work_product_c = model.get('allocated_work_product_c');      
        
        var TS_API = "rest/v10/ANML_Animals/" + rowid + "?fields=allocated_work_product_c";        
            App.api.call("get", TS_API, null, {
                    success: function(TSData) {
                        var old_allocated_WP_value = TSData.allocated_work_product_c;
                        console.log('TS_API data : ', TSData);
                        console.log('TS_API data : allocated_work_product_c : ', old_allocated_WP_value); 
                                   
                    if (old_allocated_WP_value != allocated_work_product_c && allocated_work_product_c!='' ) {
                   
                      app.alert.show('Allocated_WP_check_pop_up', {
                          level: 'confirmation',
                          messages: 'These animals are already allocated, are you sure you want to re-assign?',
                          autoClose: false,
                          confirm: {
                              label: "Yes"
                          },
                          cancel: {
                              label: "No"
                          },
                          onCancel: function() {
                             return;
                          },
                          onConfirm: function() {                     
                             model.save();                        
                          }
                      });
                  } else {
                      setTimeout(function() {
                        model.save();
                     }, 2000);
                     
                      //this._super('saveClicked', [evt]);
                  }
                    }
             });
      
                
    },
    })      

    I am using the same , Alert box is working but the issue is that default save method called before the aler box populate. I want to use the save option only on onconfirm click , How can we disable auto save for this function ?

Children