Automatic value populate on form field, based on selection of another field

I have created table StudentDetails,


Name

RegId

Aniket

1000

Aniket

1001

In Form,
I have 2 fields on form
Name – it has lookup values to select, it shows all the records(2columsn – name, RegId) in table StudentDetails
RegID – value to this filed should populate automatically based on “name” selected in above field.

Problem is in my example I have 2 records with same name, If user select second name, then RegID should populate with value “1001”

Any suggestions to handle above scenario.

Thanks

you need to set the number sequence for the reg id as this is urs custome table

http://msdax.wordpress.com/2011/09/18/new-number-sequence-implementation-in-dynamics-ax-2012/

Hi Rohit,

Thanks for you reply.

Actually you understood my issue wrongly, here already I have 2 records in table.

facing issue in form for populating value for second field based on selection of first field.

What’s your version of AX? If it’s AX 2012, use a surrogate key and you’ll get rid of the whole problem.

Hello Martin,

version - AX2009

First of all, the reference should be based on ID, not on Name, exactly because Name isn’t a unique identification of a record.

Then you can either either do an additional select to StudentDetails table to get the name, or you can implement a lookup form that will set more than one field (e.g. Lookup form returning more than one value).

Or you can forget about copying Name completely and simply add a join with StudentDetails table to get the name.

If it’s in form try like dis…

Use SysTableLookup Class in lookup method of form control( RegID) for customized lookup

and then use modified method of Control RegId.

when you select RegId it will give the lookup(Name,RegId) and it auto populates field(Name).

Lookup()// RegId contol

{

sysTableLookup.addLookupfield(fieldnum(StudentDetails, Name),False);

sysTableLookup.addLookupfield(fieldnum(StudentDetails, RegId),True);

}

Modified()// RegId Control

{

Super();

StudentDetails.Name =Table::find(RegId).Name; // get the data from customized table.

}

regards,
Krishna.

(That’s one of possible implementation of the option with an additional select.)