Put a stringEdit in the form and set the AutoDeclaration to Yes, set the name to something you will remember ; <name of control>
In the init method of the form;
query msQuery = new Query();
QueryBuildDataSource msQbds;
container cont;
super();
Fill the control from a query
msQbds = msQuery.addDataSource(tableNum(<tablename>));
msQbds.fields().dynamic(NoYes::Yes);
msQbds.fields().addField(fieldNum(<tablename>,<fieldname>));
msCtrlGroup = SysLookupMultiSelectCtrl::constructWithQuery(element,<name of control> ,msQuery);
If you wanted to pre-select (tick) some of the data using the drop-down, do this in the init method
cont = str2con("3-BookedSV;4-Diagnose;6-QuoteA",";",false);
msCtrlGroup.set(this.presetStatus(cont));
<tempfile>_ds.executeQuery();
The presetStatus sets the filter
private container presetStatus(container _container)
{
<Table> <table>;
int counter,containerLength;
str 20 lookFor;
container <visibleItem>,<recordIdOfItem>;
containerLength = conLen(_container);
for(counter=1;counter<=containerLength;counter++)
{
lookFor = conPeek(_container,counter);
select <table> where <table>.<visibleItem> == lookFor;
<visibleItem>+= [<table>.<visibleItem>];
<recordIdOfItem> += [<table>.RecId];
}
return [<recordIdOfItem>,<VisibleItem>];
}
Now make a population method to fill your temp table and add this to check to see if data should be inserted in to the temp table;
If the selection is empty, get all the data, otherwise loop through the ticked items and pick only those records
groups = <name of control>.getSelectedFieldValues();
insertData = false;
if(conPeek(groups,1) == "")
{
insertData = true;
}
else
{
CountMax = conlen(groups);
for(counterounter=1;counter <= countMax;counter++)
{
if(any2str(conPeek(groups,counter)) == <itemToCheck>)
{
insertData = true;
}
}
}
wmpSS.clear();
if(insertData)
{
Insert data in here
}
else
{
continue();
}
And finally override the executeQuery method in the temp table
public void executeQuery()
{
delete_from <tempTable>;
<tempTable>.linkPhysicalTableInstance(element.populate());
super();
}