Lookup problem

HI,

I have test table with two fields like Id,Name.I create lookup in form using this table then I select on the lookup I always select first field in this lookup like Id…Anyone suggest me how can I get second column like Name value using lookup?

Thanks in advance,

Nimisha Patel

How you are getting the lookup to the field…

By using the EDT and its relation …

or have you written any code in the lookup method for the field in the form???

Hi Nimisha,

How u created lookup ? Using EDT or Overriding Lookup method in the form…

If ur overriding the lookup method means, Set the name field as the first lookup field in ur coding.

Hi,

Here ,a code which I used to create lookup,

tableLookup = SysTableLookup::newParameters(tableNum(Test),this);
tableLookup.parmUseLookupValue(false);
tableLookup.parmQuery(q);
tableLookup.addLookupfield(fieldNum(Test,Id));
tableLookup.setLabel(“Id”);
tableLookup.addLookupfield(fieldNum(Test,Name));
tableLookup.performFormLookup();

I want to select Id field in lookup and get value of Name related to selected Id field…

Auto declaration - yes , the field to which you giving the lookup…(in the design)

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(YourTable),AutoDeclaredFieldName);

Query query = new Query();

QueryBuildDataSource queryBuildDataSource = query.addDataSource(tablenum(YourTable))

;

sysTableLookup.addLookupfield(fieldnum(YourTable,Name));

sysTableLookup.addLookupfield(fieldnum(YourTable,ID))

queryBuildDataSource.addSortField(fieldnum(YourTable,Name));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

In ur coding ,

Exchange the addlookupfield lines like this,

tableLookup.addLookupfield(fieldNum(Test,Name));

tableLookup.addLookupfield(fieldNum(Test,Id));

Thanks, But I don’t want to exchange field order and get value in lookup.

Again Thanks,

Nimisha Patel

Is there any specific reason for that - or you simply want to know how to do???

Hi ,

Try this Code…

tableLookup = SysTableLookup::newParameters(tableNum(Test),this);
tableLookup.parmUseLookupValue(false);
tableLookup.parmQuery(q);
tableLookup.addLookupfield(fieldNum(Test,Id));
tableLookup.setLabel(“Id”);
tableLookup.addLookupfield(fieldNum(Test,Name),true); // add “TRUE” here
tableLookup.performFormLookup();

Thank you very much…it is useful for select any column in lookup.

But I have one more question…In asp.net ,In dropdown control ,it give facility to bind both text field and value field…Is if possible in dynamics Ax 2009?

Again Thanks,

Nimisha Patel