I have created table StudentDetails,
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 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.
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
Modified()// RegId Control
StudentDetails.Name =Table::find(RegId).Name; // get the data from customized table.
(That’s one of possible implementation of the option with an additional select.)