During development we have to create custom inquiry forms. Or Form where we can search and filter records on different criteria.
Consider a scenario, where we have to build custom inquiry form for all saleline. In this inquiry or custom list form, we can filter on records on date, customer and amount or discount.
Lets do this,
Create a form with name custom Sales
From expend its designs and right click on design to open its property window
From property window set its design style to simplelist
Now add new data source on form, and sets create and edit property to no, Because we did not want to insert , update and delete operation on this form.
Now drag and drop following fields form data source to grid.
Now right click on grid and set its datasource to salesline.
Now run the form its look like similar
Now above grid, add group control and set its column property to 2, also set its visible property to true.
Add String Edit control, and button here.
Right click on String Edit control and set its auto delecaration to true, so we can access this control in x++. Set its name as “txtCustomerNum”. And set its lookup property to always.
Now we are going to create Unbound control with lookup,
Right lock on methods under stringEditcontrol and add lookup method.
Add following code to fill the lookup to customer and Name which belongs to current legal entity.
public void lookup()
Query query = new Query();
QueryBuildDataSource queryBuildDataSource, qbds, dsView;
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CustTable), this);
sysTableLookup.addLookupField(fieldNum(CustTable, Party), false);
queryBuildDataSource = query.addDataSource(tableNum(CustTable));
qbds = queryBuildDataSource.addDataSource(tableNum(DirPartyTable));
qbds.addLink(fieldNum(CustTable, Party), fieldNum(DirPartyTable, RecId));
dsView = qbds.addDataSource(tableNum(DirPartyPostalAddressView));
dsView.addLink(fieldNum(DirPartyTable, RecId), fieldNum(DirPartyPostalAddressView, Party));
Now run the form lets see the how behave the lookup control.
Man its working. Now check that selected value from this textbox is accessible, then we move to filter the records
Add Click event/ method on button we just added with this string edit button.
And right following code.
Now run the form, select customer and click on button.
Now right click on Salesline datasource and over rights its execute Query method.
And add following lines to filter it.
public void executeQuery()
QcustomerFilter = SysQuery::findOrCreateRange(SalesLine_q.datasourceTable(tableNum(SalesLine)),fieldNum(SalesLine,CustAccount));
In button click even add this line code
Now run the form, select the customer and click on button, you will find the filter records on form
In next post will add more filters to this form.