AnsweredAssumed Answered

Load the drawer after all the data set in app.data.createBean is saved

Question asked by Roland Cadavos on Jun 22, 2016
Latest reply on Aug 22, 2016 by Alan Apter

I have this code but the first click on event doesnt fetch the collection. If i cancel the drawer and click again, till then the data has been loaded.

 

             var locationsget = app.data.createBeanCollection('Location');

             var requestget = locationsget.fetch({"filter": [{'address_postalcode_c':postalcode_val}]});

             var locationset = app.data.createBean('Location');

             requestget.xhr.success(function(data){

                            if (_.isEmpty(data.records)){

                                for (var i=0; i< mydata.length; i++){

                                    locationset.set({

                                        // my external data is set here. no problem with this

                                    });

                                    locationset.save(null,{

                                        success:function() {console.log('success_save');},

                                        error:function() {console.log('error');}

                                    });

                                }   

                            }

                            app.drawer.open({

                               layout: 'selection-list',

                               context: {

                                    module: 'Location',

                                    collection: locationsget,

                                    filterOptions: {auto_apply:false},

                               }

                           });

             });

 

The first collection is triggered before all the .save() data is successfully saved. Any help will do.

 

Thanks,

Roland

Outcomes