give fields value automatically


I m using Dynamics ax 2009

i have 3 tables with diff fields given

vehiclecharge - vehicle type-enum, vehicle name, utc timedate, chargesperkm-int, city state currency

customer -custid, custname,pick up location and drop location

rental…- vehicle type (look up to vechicle charge),vehicle name( from vehichle charge),city, pick up location, drop location,

kmstravelled , time started ,amount

now in rental form

Now i want to

get corresponding pick up location n drop location should automatically when i put vehicle type and vehicle name in grid as soon as i write i should get pick up and drop location fields automatically filed in a form.

also in field i there which contains kms travelled as soon as i write them i should get calculated amt in amt field

amt= kms*(charges/km)

which method should i use??

the record should be sync with and from vehicle charge and cust table … how do i do this??

Hi Nick,

In order to get the lookup based on some field u can override the lookup method of the field under Datasource>field>lookup(Method).& under that lookup u can write your logic for lookup using query, querybuilddatasource.

And also u can get the lookup using EDT in ax 20009.

For: amt= kms*(charges/km)

Now, when u want the amount field to get filled up automatically then you should overrride the kms(field) modified method and write the query (amt= kms*(charges/km)) and then override the charges/km(field) modified method and write the same query as (amt= kms*(charges/km)).

Using Edt i m having sql error, can u show me an example for look up without edt?

You can syncronize your database once if it gives error on EDT.

For lookup here is the code:

public void lookup()


SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(TaxWithholdTable), this);

Query query = new Query();

QueryBuildDataSource queryBuildDataSource;


sysTableLookup.addLookupfield(fieldnum(TaxWithholdTable, TaxWithholdCode));

sysTableLookup.addLookupfield(fieldnum(TaxWithholdTable, TaxWithholdName));

queryBuildDataSource = query.addDataSource(tablenum(TaxWithholdTable));





will i get values automatically in grid using this ??


i m Not getting the values automatically i nor in look ups…i want to get automatic value in grid by just selecting the custid is there any method for it …so when i select cust id i get is realative pickup and drop point

sorry got the lookups but not the value in grid automatically…pls also tell any methods so that when i select cutid i get corresponding records of drop and pick up auto matically

hi ,

use datasource modified method for the vehicle type field …

as soon as u change the vehicle type… write as…

vehicle vehicle; ( vehicle table where vehicle type, pick up loc, drop loc are available)


select firstonly vehicle

where vehicle.vehicletype == vehicleds.vehicletype(datasourcemodifying);

if (vehicle)


vehicleds.pickuploc = vehicle.pickuploc;

vehicleds.droploc = vehicle.droploc;


i want to get pick up and drop location from customer table and the current table where i m selecting cusid is rental table so how do i do using two tables u have shown a very nice code but it includes only 1 table…can u pls show with 2 tables

do i need to use pack and unpack methods for it? if yes then how?

chaitanya thanks for reply

by writing the following code i m able to display values automatically but the problem now is that i m getting the pick up and drop location for all the records not for the particular current record…

public boolean modified()
boolean ret;
RentalTable r;
CustoTable custoTable;
int a;


ret = super();

a = RentalTable_CustId.value();

select firstonly custoTable

where custoTable.CustId == a ; //(datasourcemodifying)

if (custoTable)


r.PickupLocation = custoTable.PickupLocation;
r.DropLocation = custoTable.DropLocation;



return ret;

not getting values in grid still do i need to update or insert records? rest all is completed…

it gives error in update…