Hope you can help. Sorry for the long question. I have tried to hilite the questions and added all my code.
If anyone has any good sources on how to best extend reports with parameters etc I would greatly appreciate it.
I have to customize the CustAgingReport by adding a new parameter.
They want to be able to filter all the transactions on a LedgerDimension (Location). Note!!! On the report it is referred to as Branch
I have extended the following classes and extended the CustAgingReportTmp with new field PASLocation
CustAgingReportContract
[ExtensionOf(classStr(CustAgingReportContract))]
final class CustAgingReportContractPAS_Extension
{
private PASBranch pasBranch;
[
DataMemberAttribute(identifierStr('PASBranch')),
SysOperationLabelAttribute(literalStr("@PAS:Branch")),
SysOperationHelpTextAttribute(literalStr("@PAS:BranchHT"))
]
public PASBranch parmPASBranch(PASBranch _pasBranch = pasBranch)
{
pasBranch = _pasBranch;
return pasBranch;
}
}
CustAgingReportController I extended it using Coc to call my Reports with layout change and new field
Also extended the CustAgingReportUIBuilder to add a lookup
[ExtensionOf(ClassStr(CustAgingReportUIBuilder))]
final public class CustAgingReportUIBuilderPAS_Extension
{
private DialogField pasBranchField;
private PASBranch pasBranch;
private CustAgingReportContract contract;
//[Wrappable(false)]
public void build()
{
contract = this.dataContractObject() as CustAgingReportContract;
pasBranchField = this.addDialogField(methodStr(CustAgingReportContract, parmPASBranch), contract);
pasBranchField.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(CustAgingReportUIBuilder, pasBranchLookup), this);
next build();
}
///
/// Creates a branch lookup using values from locatin dimensions
///
public void pasBranchLookup(FormStringControl _control)
{
Query query = new Query();
// create a table lookup
SysTableLookup sysTablelookup = SysTableLookup::newParameters(tableNum(DimensionAttributeValue), _control);
sysTablelookup.addLookupfield(fieldNum(DimensionAttributeValue, Displayvalue));
// create a query
QueryBuildDataSource qbdsValue;
QueryBuildDataSource qbdsAttr;
QueryBuildRange qbrLoc;
qbdsValue = query.addDataSource(tableNum(DimensionAttributeValue));
qbdsAttr = qbdsValue.addDataSource(tableNum(DimensionAttribute));
qbdsAttr.relations(true);
qbdsAttr.joinMode(JoinMode::ExistsJoin);
qbrLoc = qbdsAttr.addRange(fieldNum(DimensionAttribute, Name));
qbrLoc.value('Location');
//qbrLoc.value(SysQuery::valueLike(queryValue('Location')));
// assign the query and call lookup
sysTablelookup.parmQuery(query);
sysTablelookup.performFormLookup();
}
}
If you look at the following screencap you will see the Branch with lookup (1) but what is causing this ghost field (2) and how do I remove it.

Further I created an eventHandler class of CustAgingReportDP to add the Branch(Location) to all the lines and then if there was a filter to delete all lines that did not belong the selected filtered Branch (Location). This is my work around . However when debugging I do not get any value in the contract.parmPASBranch. It is always empty. What am I missing?
class PASCustAgingReportDPEventHandler
{
[PostHandlerFor(classStr(CustAgingReportDP), methodStr(CustAgingReportDP, processReport))]
public static void CustAgingReportDP_Post_processReport(XppPrePostArgs args)
{
CustAgingReportDP dataProvider = args.getThis() as CustAgingReportDP;
CustAgingReportTmp custagingReportTmp = dataProvider.getCustAgingReportTmp();
CustAgingReportContract contract = dataProvider.parmDataContract() as CustAgingReportContract;
CustTable custTable;
DefaultDimensionView defaultDimensionView;
GeneralJournalAccountEntry generalJournalAccountEntry;
GeneralJournalEntry generalJournalEntry;
Dimensionattribute dimensionattribute;
DimensionAttributeValue dimensionAttributeValue;
DimensionAttributeLevelValueView dimensionAttributeLevelValueView;
//Customization for adding new fields on CustAgingReport
try
{
ttsbegin;
update_recordset custagingReportTmp
setting
PASLocation = defaultDimensionView.DisplayValue
join generalJournalEntry
where generalJournalEntry.SubledgerVoucher == custagingReportTmp.Voucher
join generalJournalAccountEntry
where generalJournalAccountEntry.GeneralJournalEntry == generalJournalEntry.RecId
outer join dimensionAttributeLevelValueView
where dimensionAttributeLevelValueView.ValueCombinationRecId == generalJournalAccountEntry.LedgerDimension
join dimensionAttributeValue
where dimensionAttributeValue.recid == dimensionAttributeLevelValueView.AttributeValueRecId
join dimensionattribute
where dimensionattribute.RecId == dimensionAttributeValue.DimensionAttribute
&& dimensionattribute.Name == 'Location';
ttscommit;
}
catch
{
error("@PAS:ErrorAddingBranchToReport"); //Error adding branch to report;
}
PASBranch branchParm;
branchParm = contract.parmPASBranch();
if(branchParm)
{
ttsbegin;
delete_from custagingReportTmp where custagingReportTmp.PASLocation != branchParm;
ttscommit;
}
}
}