Need RecId for the Selected Record in the Lookup

Hi All,

I am New to Dynamics ax 2009,I want the Recid For the selected Record in the look up. The code

public void lookup(FormControl _formControl, str _filterStr)

{

Vendtable VendTable;

Loans Loans;

Query query = new Query();

QueryBuildDataSource dsLinkedLoanNoInfo;

QueryBuildDataSource dsLoanInstallment;

QueryBuildDataSource dsVendTable;

// LoanInstallment objLoanInstallment;

//LoanId LoanId;

SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(LoanInstallment), _formControl);

;

select firstonly vendTable where vendTable.AccountNum == LedgerJournalTrans.AccountNum;

dsLoanInstallment =query.addDataSource(tablenum(Loaninstallment));

dsLoanInstallment.addRange(fieldnum(LoanInstallment,Status)).value(queryValue(Loaninstallmentstatus::Open));

dsLinkedLoanNoInfo = dsLoanInstallment.addDataSource(tableNum(LinkedLoanNoInfo));

dsLinkedLoanNoInfo.addRange(fieldnum(LinkedLoanNoInfo,LinkedLoanNumber)).value(LedgerJournalTrans.AccountNum);

dsLinkedLoanNoInfo.relations(true);

dsLinkedLoanNoInfo.joinMode(JoinMode::ExistsJoin);

sysTableLookup.addLookupfield(fieldNum(LoanInstallment,InstallmentCode));

sysTableLookup.addLookupfield(fieldNum(LoanInstallment,InstallmentAmount));

sysTableLookup.addLookupfield(fieldNum(LoanInstallment,LoanId));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

While After selected the record ,I need the recid of the record

How I can take that recid?

Thanks

md rhiyas

Just write following code

sysTableLookup.addSelectionfield(fieldNum(LoanInstallment,RecId));

below

sysTableLookup.addLookupfield(fieldNum(LoanInstallment,LoanId));

Thanks Lalit,

But I want to Store the recid in One variable ,How can I do that ?

Thanks

md rhiyas

You posted a method Lookup which is only responsible for showing user fields in a dropdown (lookup). If you want to show user also RecId along with InstallmentCode, InstallmentAmount and LoanId, you should do what Lalit suggested.

But after that you said that you need to store the value of RecId in a variable. Of course this can be done, but Lookup method is not the place to get it. You can write a select statement where you filter records from LoanInstallment table based on the selected value in the formControl and then you’ll be able to get the value. But this will work only if the value stored in formControl is unique and can identify only one record. There can be an easier way to do what you want, we just need to know where do you want this value and which field is stored in the formControl.

yes,Ofcourse

Thanks