Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

contract object not initialized

(0) ShareShare
ReportReport
Posted on by 65

FRVMSIPspiffOverrideReportController Class:

class FRVMSIPSpiffOverrideReportController extends SrsReportRunController
{
}

protected void preRunModifyContract()
{
    VMSipAllowanceHeader header;

    super();

    if(this.parmArgs() && this.parmArgs().record())
    {
        this.parmReportContract().parmReportName(ssrsReportStr(FRVMSIPSpiffOverrideReport, FRVMSIPSpiffOverrideReport));
        this.parmReportName(ssrsReportStr(FRVMSIPSpiffOverrideReport, FRVMSIPSpiffOverrideReport));
    }
}

public static void main(Args _args)
{
    VMSipAllowanceHeader headerInfo;

    List programIds = new List(Types::String);

    FRVMSIPSpiffOverrideReportContract contract = new FRVMSIPSpiffOverrideReportContract();

    MultiSelectionHelper selectedSpiffs = MultiSelectionHelper::createFromCaller(_args.caller());

    FRVMSIPSpiffOverrideReportController controller = new FRVMSIPSpiffOverrideReportController();

    headerInfo = selectedSpiffs.getFirst();

    if(headerInfo)
    {
        while (headerInfo)
        {
            programIds.addEnd(headerInfo.ProgramId);

            headerInfo = selectedSpiffs.getNext();
        }
    }

    contract.parmProgramIds(programIds);

    controller.parmArgs(_args);

    controller.parmReportName(ssrsReportStr(FRVMSIPSpiffOverrideReport, FRVMSIPSpiffOverrideReport));

    controller.parmShowDialog(false);

    controller.startOperation();
}

FRVMSIPSpiffOverrideReportDP Class:

[
    SysEntryPointAttribute(false)
]
public void processReport()
{
    gVMSpiffOverrideReportTmp.clear();

    contract = this.parmDataContract() as FRVMSIPSpiffOverrideReportContract;
    
    _programIds = contract.parmProgramIds();

    if(_programIds != null)
    {
         programIdsListIterator = _programIds.getEnumerator();

         while(programIdsListIterator.moveNext())
        {
            programId = programIdsListIterator.current();

            while select allowanceHeader where programId == allowanceHeader.ProgramId
                join allowanceLine where allowanceHeader.RecId == allowanceLine.RecId
                join salesLine where allowanceLine.SalesLine == salesLine.RecId
                join spiffOverride where spiffOverride.AllowanceHeader == allowanceHeader.RecId
                join custTable where CustTable.RecId == allowanceLine.CustTable
                join inventTable where InventTable.RecId == spiffOverride.InventTable
                join spiffChassis where spiffChassis.AllowanceHeader == allowanceHeader.RecId
                join inventSite where inventSite.SiteId == allowanceHeader.InventSiteId
                join siteMapping where (siteMapping.SiteId == inventSite.SiteId && siteMapping.user == curUserId()) ||
                (siteMapping.user == curUserId())

            gVMSpiffOverrideReportTmp.ProgramIds = allowanceHeader.ProgramId;

            gVMSpiffOverrideReportTmp.SiteId = allowanceHeader.InventSiteId;

            gVMSpiffOverrideReportTmp.VMShortVIN = allowanceLine.frShortVIN;

            gVMSpiffOverrideReportTmp.VMVINNumber = allowanceLine.VINInfo;

            gVMSpiffOverrideReportTmp.Active = spiffOverride.frActive;

            gVMSpiffOverrideReportTmp.Amount = spiffOverride.Amount;

            gVMSpiffOverrideReportTmp.CustGroup = custTable.CustGroup;

            gVMSpiffOverrideReportTmp.CustomerDescription = spiffOverride.dispCustName(spiffOverride);

            gVMSpiffOverrideReportTmp.SalesGroup = CustTable.SalesGroup;

            gVMSpiffOverrideReportTmp.ItemNumber = inventTable.RecId;

            gVMSpiffOverrideReportTmp.ItemDescription = spiffOverride.dispItemDescription(spiffOverride);

            gVMSpiffOverrideReportTmp.OverrideNote = spiffOverride.frSipOverrideNote;

            gVMSpiffOverrideReportTmp.PaymentDate = spiffOverride.frDispTransDate();

            gVMSpiffOverrideReportTmp.ValidFrom = spiffOverride.ValidFrom;

            gVMSpiffOverrideReportTmp.ValidTo = spiffOverride.ValidTo;

            gVMSpiffOverrideReportTmp.insert();
        }
    }
}

The error occurs when I reach this line in the processReport method of my DP:

_programIds = contract.parmProgramIds();

Do I need a parmContract method to hold the contract instead of just the new statement in the controller class?

  • JGjinx321 Profile Picture
    65 on at
    RE: contract object not initialized

    Thanks!

  • Verified answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: contract object not initialized

    I think you missed the line of code pass to contract values to parmRdpContract method of controller class. Refer to the main method of controller class.

    public static void main(Args _args)
    {
        VMSipAllowanceHeader headerInfo;
    
        List programIds = new List(Types::String);
    
        FRVMSIPSpiffOverrideReportContract contract = new FRVMSIPSpiffOverrideReportContract();
    
        MultiSelectionHelper selectedSpiffs = MultiSelectionHelper::createFromCaller(_args.caller());
    
        FRVMSIPSpiffOverrideReportController controller = new FRVMSIPSpiffOverrideReportController();
    
        headerInfo = selectedSpiffs.getFirst();
    
        if(headerInfo)
        {
            while (headerInfo)
            {
                programIds.addEnd(headerInfo.ProgramId);
    
                headerInfo = selectedSpiffs.getNext();
            }
        }
    
        contract.parmProgramIds(programIds);
    
        controller.parmArgs(_args);
    
        controller.parmReportName(ssrsReportStr(FRVMSIPSpiffOverrideReport, FRVMSIPSpiffOverrideReport));
    
        controller.parmShowDialog(false);
        //this is the line added to pass contract values.
        controller.parmReportContract().parmRdpContract(contract);
        
        controller.startOperation();
    }

    Also don't forget to decorate the DP class with dc class using the attribute.

    [
      SRSReportParameterAttribute(classStr(FRVMSIPSpiffOverrideReportContract))
    ]
    public class YourRDPClassName extends SrsReportDataProviderPreProcess
    {
        
    }

    Thanks,

    Girish S.

  • JGjinx321 Profile Picture
    65 on at
    RE: contract object not initialized

    Hi Girish, I've added a few things to my code that I will update in the original post.

    (The parm method you mentioned as well as tmpTable.clear())

    I've added your statement. When I run through the debugger the method seems to try and pull a parm'd contract from the method. But the value returned back is null.

    It's like it still doesn't recognize that previous contract class instance I created in my controller when assigning values to a parameter.

    Do you know why this is?

    I see in the tutorial the process for this is the same. So I can't think of much myself besides the fact for my contract class I'm extending SysOperationInitializable.

    For my data class I'm extending SrsReportDataProviderPreProcess.

  • JGjinx321 Profile Picture
    65 on at
    RE: contract object not initialized

    Thank you! :)

  • GirishS Profile Picture
    27,825 Moderator on at
    RE: contract object not initialized

    You know need to call the specific class. It will be done automatically by standard. Report will start from -

    Controller class - Controller class will contain the basic information about report dialog caption - Name of the report design.

    UI builder class - This class is mainly used to represent the dialog shown to the user in more representative way - Adding lookup to the control etc.

    Contract class -This class will have parm methods and values given from the dialog box is assigned to parm methods.

    Data provider class (DP) - This is the class which container business logic for the report - Get the contract class instance using contract = this.parmDataContract() as FRVMSIPSpiffOverrideContract.

    Now using that contract buffer, you can get the values given in the report dialog and based on that filter you can write code to insert record into temp table.

    Refer to the below link.

    https://community.dynamics.com/ax/b/dynamics101trainingcenterax/posts/developing-a-ssrs-report-using-the-report-data-provider-in-microsoft-dynamics-ax-2012

    Thanks,

    Girish S.

  • JGjinx321 Profile Picture
    65 on at
    RE: contract object not initialized

    So from my knowledge, we first go to the contract class >  then controller class.

    I initialize FRVMSIPContract in main method of controller class.

    After finishing my controller main method loop, I then call your statement contract = this.parmDataContract() as FRVMSIPSpiffOverrideContract???

    From there, in my DP.ProcessReport I can then call that instance of the contract class and get the controller main method loop values I wanted to bring to DP?

    Would that call be the same statement used to store contract class value? Or is it another statement to retrieve information???

    Sorry if it's a lot of questions.

    Still just trying to get my understanding down correctly.

  • Suggested answer
    GirishS Profile Picture
    27,825 Moderator on at
    RE: contract object not initialized

    Hi JGjinx,

    You need to make use of the parmDataContract method to get instance of contract class.

    contract = this.parmDataContract() as contractClassName.

    Thanks,

    Girish S

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans