Displaying particular record in a lookup

Hi All,

I have a lookup for sales order no field and it displays all fields in salestable table in this sales table there is a field displaying status of the sales whether it is open order or invoiced,etc. Now what i need to know is the lookup need to show only the details related to open order (i.e) in the status field I need only the open order sales must be shown I don’t want other invoiced or posted records to be displayed. I use AX 2009 version.

Thanks & Regards,

Raaj

You can filter it in the select/while condition.

SalesTable.SalesStatus::OpenOrder;

Hi Vijay,

Can you please give me a detailed explanation with sample coding.

This method will help you: http://daxtechies.blogspot.in/2013/03/lookup-or-drop-down-for-field-in.html

Table name will be ‘SalesTable’ and under range you can pass ‘SalesStatus’ as Open order

You can also do it through relations. Give relation with sales table on your table where you want the lookup

  1. Normal = SalesId to SalesId and

  2. Related Fixed Field 1 = SalesTable.SalesStatus

Hi Naveen,

Please try to override lookup method of the string edit control SalesId. In that you have to write code for building x++ query. in that you can add datasources, ranges and can provide the range value as well. Then it will filter the lookup based on the range value like all the open sales orders.

Thanks,

Vijay Solanki.

Your lookup method will have this code. The SaledIdEdit is the string control in my case, in which I am performing the lookup and override the lookup method of this control. Try this snippet, I hope you will find your answer. Don’t forget to mark this as solution.

public void lookup()

{

SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(SalesTable),SalesIdEdit);

Query query;

QueryBuildDataSource queryBuildDataSource;

QueryBuildRange queryBuildRange;

;

// Parameter “true” indicates what field

// is returned to the form

sysTableLookup.addLookupfield(

fieldnum(SalesTable,

SalesId),

true);

sysTableLookup.addLookupfield(

fieldnum(SalesTable,

SalesName));

sysTableLookup.addLookupfield(

fieldnum(SalesTable,

SalesStatus));

query = new Query();

// Add datasource to the query

queryBuildDataSource = query.addDataSource(

tablenum(SalesTable));

// Add sorting index to query

queryBuildDataSource.addSortIndex(

indexnum(SalesTable,

SalesIdx));

//Add range to the query

queryBuildRange = queryBuildDataSource.addRange(fieldNum(SalesTable,SalesStatus));

queryBuildRange.value(enum2str(SalesStatus::BackOrder));

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();

}

Thank you Vijay, Vishal and Anand I don’t know who’s suggestion helped me but I got the solution.

Thanks & Regards,

Raaj