AnsweredAssumed Answered

Replace a value of a form - SugarCRM 7

Question asked by brunoribeiro brunoribeiro on May 27, 2015
Latest reply on May 27, 2015 by brunoribeiro brunoribeiro
Hi guys, I'm new to Sugar, I'm having trouble replacing a value in a form within the SugarCRM 7, you could assess my code, I do not know what I'm missing, it is Google's base of returning the information correctly, but when I try to provide the city or state to form the model.set code does not work, I tried to put $ ("# field"). val ('value') did not work, what can I be missing?

Code below:

 _automatic_zip_code: function() {     
        //example of getting field data from current record
        var AcctID = this.model.get('id');
        var cidade = this.model.get('billing_address_city');
        var cep = this.model.get('billing_address_postalcode');
   
  var endereco = cep; 
 
  geocoder = new google.maps.Geocoder();
 
  geocoder.geocode({ 'address': endereco + ', Brasil', 'region': 'BR' }, function (results, status) {
   if (status == google.maps.GeocoderStatus.OK) {
    if (results[0]) {
    
     var latitude = results[0].geometry.location.lat();
     var longitude = results[0].geometry.location.lng();    
     var enderecocompleto = results[0].formatted_address;   
     var enderecoarray = enderecocompleto.split(',');        
         
     alert(enderecoarray[0] + "" + enderecoarray[1] + " " + enderecoarray[2] + " " + enderecoarray[3]);
             
     app.alert.show('message-id', {
      level: 'confirmation',
      messages: 'Confirm '+ enderecoarray[0] + "" + enderecoarray[1] + " " + enderecoarray[2] + " " + enderecoarray[3],
      autoClose: false,
      onConfirm: function(){
        alert("Confirmed!");
        this.model.set('billing_address_city', 'asdasdasdsa');
        $('#billing_address_city').val(enderecoarray[0]);
        
        this._super('_render');
      },
      onCancel: function(){
       alert("Cancelled!");
      }
     });
    
     //var location = new google.maps.LatLng(latitude, longitude);
     //marker.setPosition(location);
     //map.setCenter(location);
     //map.setZoom(16);
    }
   }
  });       
    },

Outcomes