Exclude Items on the Item Lookup forms and the ItemTable Form

Currently we are on Navision Axapta 3.0 SP 5; We have been using Axapta for several years and have a lot of items that have become inactive and are discontinued. Unfortunately the lookups show all the items - and our customer service has a tendency to overlook the X’s and Discontinued statements on the item when speaking to customers.

I need to be able to get the InventTable form to not show the inactive/discontinued items, and I also want the InventItemIDLookupSimple Form to exclude these items as well. The InventItemIdLookupSimple Form appears to be the one used for the various orders that have Itemid lookups. On the InventTable form I would like to have it so that I can remove that filter option if I choose - but that the default would be that it excludes those items.

Any help would be appreciated. I am still new to the programming side of the system - so code examples would be very appreciated.

This should be posted in the Axapta forum not the Navision.

but as a note we have a ton of discontinued items too 5000+

In Nav we can filter them out - but In case a person needs to see all the items I have the discontinued (Blocked) item DESCRIPTION turn RED. It’s alot more visible than trying to notice an “X” or something.

As you probably have noticed - the blocked checkbox is repeated 3 times for each item - 1 for each module type (Invent, Purch, Sales)

Here is an example of a simple lookup that includes filtering on non-blocked items - but what you have to do is pass on the module it is used it.

client static void lookupItemId(FormStringControl _fc, ModuleInventPurchSales _module)
{
sysTableLookup sysTableLookup;
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildDataSource queryBuildDataSourceModule;
QueryBuildRange queryBuildRange;
QueryBuildRange qbrBlocked;
;

`

//this will disable the filtering on input - you can comment it out
_fc.text("");

sysTableLookup = sysTableLookup::newParameters(tableNum(InventTable), _fc);
sysTableLookup.addLookupfield(fieldNum(InventTable, itemId));
sysTableLookup.addLookupfield(fieldNum(InventTable, itemName));

query = new Query();
queryBuildDataSource = query.addDataSource(tableNum(InventTable));

//this sorts the inventory based on the name of items - mostly what users ask to do all the time
//can comment it out too
queryBuildDataSource.addSortField(fieldNum(InventTable, ItemName));

queryBuildDataSourceModule = queryBuildDataSource.addDataSource(tableNum(InventTableModule));
queryBuildDataSourceModule.addLink(fieldNum(InventTable, ItemId), fieldNum(InventTableModule, ItemId));
queryBuildDataSourceModule.addRange(fieldNum(InventTableModule, ModuleType)).value(queryValue(_module));
queryBuildDataSourceModule.addRange(fieldNum(InventTableModule, Blocked)).value(queryValue(NoYes::No));

//this will show you the formed query
// info(queryBuildDataSource.toString());

sysTableLookup.parmQuery(query);

sysTableLookup.performFormLookup();
}

I guess after reading this code you won’t have any problem modifying the form InventItemIdLookupSimple

`

The InventTable form has to be modified similarily, (the datasources are already there), as faonly you will have to add a checkbox or something on the form and then check it's value on execute query and modify the range of blocked field