How to show value in dialog on the basis of other field in MSD axapta

To show value in dialog on the basis of other field in axapta , you can try  code in report following way.

 public class Test extends ObjectRun  
 {  
    DialogField      dlgfld1,dlgfld2;  
    InventLocationId    _InventLocationId;  
    Name          _name;  
 }  
  public Object dialog(Object _dialog)  
  {  
   DialogRunbase dialog = _dialog;  
   ;  
   dialog.caption('Location Details');  
   dialog.addGroup('Select Location Id :');  
   dlgfld1 = dialog.addField(typeid(_InventLocationId),"Location Id : ");  
   dlgfld1.value(_InventLocationId;);  
   dlgfld2 = dialog.addField(typeid(_Name),"Location name : ");  
   dialog.allowUpdateOnSelectCtrl(true);  
   return dialog;  
  }  
 public void dialogSelectCtrl()  
 {  
    ;  
    dlgfld2.value(InventLocation::find(dlgfld1.value()).Name);  
 }  
 boolean getFromDialog()  
 {  
   ;  
   _InventLocationId;  =  dlgfld1.value();  
   _name   =  dlgfld2.value();  
   return true;.  
 }