AnsweredAssumed Answered

How wait execution of app.data.createBean in record.js? Sugar 7.6

Question asked by Rodolfo Jesus on Feb 19, 2016
Latest reply on Aug 23, 2016 by Alan Apter

How wait execution of app.data.createBean in record.js?

 

I need get valid field value modification, but my code not work.

var mobile = 0; 
      var obj = this;
      var leadId=this.model.get('parent_id');  
      app.data.createBean(this.model.get('parent_type'),{id:leadId}).fetch({         
              success:function(lead){  
                  mobile = lead.get('phone_mobile');      
              }  
      });
      //i need wait app.data.createBean execute
      //?????????????????????????????????
      //my mobile ever 0 zero
      if (this.model.get('phone_mobile') != mobile) {
        errors['phone_mobile'] = errors['phone_mobile'] || {}; 
        errors['phone_mobile'].custom_message_held = true;
      }
      callback(null, fields, errors); 

 

How wait app.data.createBean execute for continue code?

Outcomes