web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to extend CustAgingReport with new Parameter

(0) ShareShare
ReportReport
Posted on by 15

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.

pastedimage1654760901867v1.png

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;
        } 

    }
}

I have the same question (0)
  • Alex VN Profile Picture
    1,994 on at
    RE: How to extend CustAgingReport with new Parameter

    No problem Sophia, the most important thing that it helped to solve your problem is enough for me :D

    Please feel free to reachout to me if you need anything, share to be shared :)

  • Suggested answer
    Sophia.r Profile Picture
    235 on at
    RE: How to extend CustAgingReport with new Parameter

    Great that solved my issue. it was this line of code

    pasBranchField = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(CustAgingReportContract,parmPASBranch));

    I am not able to suggest this as the answer.  I assume because of the user mixups.  (Still no idea how that happened.

    Thank you so much Alex

  • Suggested answer
    Alex VN Profile Picture
    1,994 on at
    RE: How to extend CustAgingReport with new Parameter

    Hi Sophia,

    You can try to use this to override lookup on existing control for pasBranchField without duplicate of the control. Might have some syntax issue as I write it manually :)

    public void build()
    {
    contract = this.dataContractObject() as CustAgingReportContract;
    
    //pasBranchField = this.addDialogField(methodStr(CustAgingReportContract, parmPASBranch), contract);
    
    pasBranchField = this.bindInfo().getDialogField(this.dataContractObject(),methodStr(CustAgingReportContract,parmPASBranch));
    
    if (pasBranchField)
    
    {
    
    pasBranchField.lookupButton(2);
    
    }
    pasBranchField.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(CustAgingReportUIBuilder, pasBranchLookup), this);
    
    
    
    next build();
    }

  • Sophia.r Profile Picture
    235 on at
    RE: How to extend CustAgingReport with new Parameter

    Good Day Alex.  I am not sure what happened but the above question was posted by me and not Kytie95. Do not know how this happened. I did not receive any notifications, so excuse the late response.

    Thank you for your reply.  So first of all I tested using both the fields with different values, and it is passing the parameter through correctly when using the one without the lookup.

    Can you please give me some advice as to how to add the lookup to the field that was defined in the contract class, or what is the correct way to extend a report and how to add a lookup.

    Kind regards Sophia Retief

  • Alex VN Profile Picture
    1,994 on at
    RE: How to extend CustAgingReport with new Parameter

    Hi Kytie,

    Quick look from my side, it seems that you added the new paramater twice. One from contract extension (2) and one from your UI Builder class (1). You can see the one without lookup is the one from the contract extension.

    For the debug issue, may I know if you fill in the value in (1) or (2) text box? Also is your contract variable not null for all the field?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 665 User Group Leader

#2
Martin Dráb Profile Picture

Martin Dráb 595 Most Valuable Professional

#3
Yng Lih Profile Picture

Yng Lih 558

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans