We will assume the table as AssetTable( where the report is based on AssetTable), then write the code in init() method as
public void init()
{
if(this.args().dataset() == TableNum(AssetTable))
{
AssetTable = this.args().record();
}
super();
}
Write the InitQuery() to initialize the query which is as follows..
public Query initQuery(Query _query)
{
QueryBuildRange range;
;
query = _query;
if (AssetTable)
{
range = query.dataSourceTable(tablenum(AssetTable)).findRange(fieldnum(AssetTable,AssetId));
if (!range)
range = query.dataSourceTable(tablenum(AssetTable)).addRange(fieldnum(AssetTable,AssetId));
range.value(AssetTable.AssetId);
or
SysQuery::findOrCreateRange(query.dataSourceTable(tablenum(AssetTable)), fieldnum(AssetTable, Assetid)).value(queryvalue(AssetTable.AssetId));
}
return query;
}
Now fi you call this specified report from the form which is based on Asset Table, then the report will run for specific Asset number.
// To avoid the usage data when called from Fixed Assets form(This will stop the usage data updates)
public boolean mustLoadSaveQuery()
{
if (AssetTable)
{
return false;
}
else
{
return true;
}
}
Thanks, and hope It will helps you.
public void init()
{
if(this.args().dataset() == TableNum(AssetTable))
{
AssetTable = this.args().record();
}
super();
}
Write the InitQuery() to initialize the query which is as follows..
public Query initQuery(Query _query)
{
QueryBuildRange range;
;
query = _query;
if (AssetTable)
{
range = query.dataSourceTable(tablenum(AssetTable)).findRange(fieldnum(AssetTable,AssetId));
if (!range)
range = query.dataSourceTable(tablenum(AssetTable)).addRange(fieldnum(AssetTable,AssetId));
range.value(AssetTable.AssetId);
or
SysQuery::findOrCreateRange(query.dataSourceTable(tablenum(AssetTable)), fieldnum(AssetTable, Assetid)).value(queryvalue(AssetTable.AssetId));
}
return query;
}
Now fi you call this specified report from the form which is based on Asset Table, then the report will run for specific Asset number.
// To avoid the usage data when called from Fixed Assets form(This will stop the usage data updates)
public boolean mustLoadSaveQuery()
{
if (AssetTable)
{
return false;
}
else
{
return true;
}
}
Thanks, and hope It will helps you.