How to get selected record all column value in lookup

Hi everyone,İ have a question.İ have a table BoraxEmplTable and their method,İ have a form AlbArhivePlanTable.İ open

AlbArhivePlanTable and call this lookup method in a field like this.

public void lookup()

{

super();

BoraxEmplTable::lookupOldEmplId(this);

}

İ have 4 column in lookup.İ want all column value .How can i get all column value when i select a record in lookup.İ want EmplId,EmplName value to use .How can i get it in lookup closed?

and this is my lookup method.

public static void lookupOldEmplId(FormControl _formControl)

{

Query query = new Query();

QueryBuildDataSource queryBuildDataSource;

SysTableLookup sysTableLookup;

;

changecompany (curext())

{

query.addDataSource(tablenum(BorAXEmplTable));

sysTableLookup = SysTableLookup::newParameters(tablenum(BorAXEmplTable), _formControl);

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, OldEmplId),true);

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, EmplId));

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, EmplName));

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, BorAXDivision));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

}

İ want EmplId and EmplName value when the record is selected in lookup.Please help me!

Sinan, try the below code:

public void lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup; // systemclass to create //customlookup
Query query;
QueryBuildDataSource qbd;

;
sysTableLookup = SysTableLookup::newParameters(
tablenum(BorAXEmplTable),_formcontrol);

// Construct query on the table,
// whose records you want to show as lookup.
query = new Query();
qbd = query.addDataSource(tablenum(BorAXEmplTable));

// add the fields to the lookup list

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, EmplId),true);
sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, OldEmplId));

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, EmplName));

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, BorAXDivision));

// pass the query as parameter
// system will show the records in the lookup
// as per your query
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}

Hi Sinan,

Make some changes like below one in your form level lookup().

public void lookup(FormControl _formControl, str _filterStr)
{ DirPartyPostalAddressView::myLookup(_formControl,HeaderTable.AccountNum);
}

Thank you for replied.But i dont understand :frowning: i can show all field in lookup .But i cant get their value in form when i selected a record.how can i get their value a record in lookup.İ dont know english well.You can see Çalışan,BoraxSıraNo,ÇalışanAdı and Lokasyon.When i select A0000002 record i want GU09-001 value.i must get it.Thank you all.

What’s your version of AX?

In AX 2012, you can create a custom lookup form that sets a buffer to FormRun.selectRecordModeSelectedRecord() and later you can use the same method to read the selected record. The FormAutoLookup factory will help you to instantiate the lookup form.

Use cross-references of ormRun.selectRecordModeSelectedRecord() to find examples in standard AX.

In other versions of AX, you’ll have to make some explicit calls between the lookup form and the caller form.

My version is ax 2009 :frowning: can you give me an example ? i call lookup like BoraxEmplTable::lookup(this); and i said my lookup code above.Thank you for helping.

Hi Sinan,

I can’t understand your requirement.

If the user select the value “YE01-007” in the “Firma / Lokasyon Adi” field, you should automically fill the value “DURSUN AKSU” in the field “Firma / ÇalışanAdı”.

Is this your requirement?

Thanks,

Hari

Hi hariharan.Yes this is my requirement.But there is a problem. If the user select the value “YE01-007” in the “Firma / Lokasyon Adi” field, i cant should automically fill the value “DURSUN AKSU” in the field “Firma / ÇalışanAdı”.Because you see the record like this;

A000004 A000004 SELAHATTİN UÇAŞ YE01-007

A000006 A000006 DURSUN AKSU YE01-007

you see if i get YE01-007 i cant understand it is SELAHATTİN UÇAŞ OR DURSUN AKSU.İf i get Çalışan and BoraxSıraNo value i can automatically fill the value in the “Firma / ÇalışanAdı” field.“Firma / ÇalışanAdı” is a display method.

This is example.İ select “YE01-007” in the “Firma / Lokasyon Adi” field.But there is more people in “YE01-007”.İf i select

A000006 A000006 DURSUN AKSU YE01-007 record,İ must get A000006 value and A000006 value.İ dont know how i can solve this problem :frowning:

in lookup method this must be like this.When i select a record ,İf i get Çalışan i maybe know who is this.İ dont know english well .Sorry for this.

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, OldEmplId)); //Çalışan

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, EmplId)); //Borax Sıra No

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, EmplName)); //Çalışan Adı

sysTableLookup.addLookupfield(fieldnum(BorAXEmplTable, BorAXDivision),true); //Lokasyon

i call lookup method in “Firma / Lokasyon Adı” like this;

public void lookup()

{

super();

BoraxEmplTable::lookupOldEmplId(this);

}

Hi Sinan,

Sorry, I don’t have any idea.

Solution 1: Please add a lookup for the control “Firma / Çalışan Adı” and display the lookup based on the selected “Firma / Lokasyon Adi” value.

Solution 2: Add a lookup for the control “Firma / Çalışan Adı” and move this control before “Firma / Lokasyon Adi”. So, you can populate other values easily in this field modified method.

Thanks,

Hari

Thank you all.

Hi Sinan,

If you solved this issue, please share your solution.

Today, i got some time to research your problem. I got one solution, if the employee id is unique then, you can able to get the other values.

Please use custom lookup form, create a new method in your form “AlbArhivePlanTable” and call this method from the custom lookup form. So, you can fill the other values in your form “AlbArhivePlanTable”.

This concept is explained by Martin in this post.

Thanks,

Hari

Hi Sinan,

colleague of mine (thx Dan) solved this in following way. Use a form for lookup creation (i.e.described here http://programming4.us/enterprise/9044.aspx), create a method for processing result from lookup on the lookup caller (table/form…) than call this method in lookup form’s closeSelect method and pass selected values.