if you want to refresh a form, but want to stay on the current record you are on, use this code:
void refreshForm()
{
FormTable current;
;
if (FormTableDataSource.RecId)
{
FormTableDataSource_ds.write();
current.data(FormTableDataSource);
FormTableDataSource_ds.research();
FormTableDataSource_ds.setRecord(current);
}
Wednesday, June 9, 2010
Tuesday, June 8, 2010
GROUPING query
if you want to group a query on a field, here is an example (used in a lookup table):
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(YourTable), this);
Query query = new query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(YourTable));
;
queryBuildDataSource.orderMode(OrderMode::GROUPBY);
queryBuildDataSource.addSortField(FieldNum(YourTable, YourField));
sysTableLookup.addLookupfield(fieldNum(YourTable, YourField));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(YourTable), this);
Query query = new query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(YourTable));
;
queryBuildDataSource.orderMode(OrderMode::GROUPBY);
queryBuildDataSource.addSortField(FieldNum(YourTable, YourField));
sysTableLookup.addLookupfield(fieldNum(YourTable, YourField));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Creating Lookups
here is a sample code to create lookups on a form field
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(YourAXTable, this);
Query query = new query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(YourAXTable));
QueryBuildRange range1 = queryBuildDataSource.addRange(fieldNum(YourAXTable, FieldYouWantFiltered1));
QueryBuildRange range2 = queryBuildDataSource.addRange(fieldNum(YourAXTable, FieldYouWantFiltered2));
;
range1.value(queryValue(YourFormField.valuestr()));
range2.value(queryValue(YourFormField2.valuestr()));
sysTableLookup.addLookupfield(fieldNum(YourAXTable, FieldYouWantReturned));
sysTableLookup.addLookupfield(fieldNum(YourAXTable, AdditionalLookupColumn));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(YourAXTable, this);
Query query = new query();
QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(YourAXTable));
QueryBuildRange range1 = queryBuildDataSource.addRange(fieldNum(YourAXTable, FieldYouWantFiltered1));
QueryBuildRange range2 = queryBuildDataSource.addRange(fieldNum(YourAXTable, FieldYouWantFiltered2));
;
range1.value(queryValue(YourFormField.valuestr()));
range2.value(queryValue(YourFormField2.valuestr()));
sysTableLookup.addLookupfield(fieldNum(YourAXTable, FieldYouWantReturned));
sysTableLookup.addLookupfield(fieldNum(YourAXTable, AdditionalLookupColumn));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Sunday, June 6, 2010
QueryBuildRange date range between two dates
when you want to filter between two dates. use SysQuery::Range:
eg
queryBuildRange = queryBuildDataSource.addRange(FieldNum(WRWaterShareTable, TenureExpiryDate));
queryBuildRange.value(sysQuery::range(_expiryDateFilter,_expiryDateToFilter));
this function gives the flexibility of passing one or two dates. if you pass value in the first date only, it will search date equal to and after the date. if you pass value in the second date only, it will search dates equal to and before the date.
eg
queryBuildRange = queryBuildDataSource.addRange(FieldNum(WRWaterShareTable, TenureExpiryDate));
queryBuildRange.value(sysQuery::range(_expiryDateFilter,_expiryDateToFilter));
this function gives the flexibility of passing one or two dates. if you pass value in the first date only, it will search date equal to and after the date. if you pass value in the second date only, it will search dates equal to and before the date.
Tuesday, June 1, 2010
SysOperationProgress sample
this is the basic code of when you want to show progress. it will show the progress animation while the system is waiting to go through your code.
public void sysOperationProgressSample()
{
SysOperationProgress progress = new SysOperationProgress();
counter counter = 0;
counter progressCounter = 0;
LineNum lineNum = 0;
int lineTotal;
;
#AviFiles
progress.setCaption("Processing Records...");
progress.setAnimation(#AviUpdate);
lineTotal = 9999; //set total of lines here
progress.setTotal(lineTotal);
while select ...
{
//put these lines on top (or at the bottom of what you are doing)
counter++;
progressCounter++;
progress.setText(strFmt("Processing %1 of %2 records. Please wait",int2str(counter),int2str(lineTotal)));
progress.incCount();
/*
your stuff here
*/
}
}
public void sysOperationProgressSample()
{
SysOperationProgress progress = new SysOperationProgress();
counter counter = 0;
counter progressCounter = 0;
LineNum lineNum = 0;
int lineTotal;
;
#AviFiles
progress.setCaption("Processing Records...");
progress.setAnimation(#AviUpdate);
lineTotal = 9999; //set total of lines here
progress.setTotal(lineTotal);
while select ...
{
//put these lines on top (or at the bottom of what you are doing)
counter++;
progressCounter++;
progress.setText(strFmt("Processing %1 of %2 records. Please wait",int2str(counter),int2str(lineTotal)));
progress.incCount();
/*
your stuff here
*/
}
}
Subscribe to:
Posts (Atom)