Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Error in prePromptModifyContract() Controller Method

Posted on by 145

Hi,

I`ve been struggling with a problem. I need to launch a SSRS report from a form. For this reason I`m using a Controller class, a Contract class and a Data Provider Class.

So I Implement an Output  menu item wich has a Class as an ObjectType Property and wich is MyController.

 Controller class simply gets Args from caller and sets parameters in  Contract class. The problem is that I can not add any parameter in my Controller.

So I had an error : HC_MonthlyDecContract object not initialised.

Any Help Please?

Thx,

MenuItemProperty.png

*This post is locked for comments

  • Houda Chkoundali Profile Picture
    Houda Chkoundali 145 on at
    RE: Error in prePromptModifyContract() Controller Method

    Many Thanks Vilmos Actually I did't define  parameters in My report this is why I had the error "HC_MonthlyDecContract object not initialised." Again, Thanx

  • Houda Chkoundali Profile Picture
    Houda Chkoundali 145 on at
    RE: Error in prePromptModifyContract() Controller Method

    Many Thanks Pintu It is very helpfull :)

  • Verified answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Error in prePromptModifyContract() Controller Method

    The code above pasted by Pintu is expecting a record buffer in the caller argument.

    Again, the menu item should be used on a menuitembutton on your form, for which you need to override the clicked method in order to pass in additional arguments however you are expecting them.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error in prePromptModifyContract() Controller Method

    Here is the piece of code,

    protected void prePromptModifyContract()

    {

       YourContractClass       contract;

       YourTable                    table;

        ;

       table= this.parmArgs().record();

       contract             = this.parmReportContract().parmRdpContract() as YourContractClass       ;

       contract.parmReclId(table.RecId);//Or any Unique Field you have.

       super();

    }

    By Using this Id, populate your temporary table in DP class.

    Hope it works.

  • Houda Chkoundali Profile Picture
    Houda Chkoundali 145 on at
    RE: Error in prePromptModifyContract() Controller Method

    Thank you Pintu. Would you please clarify more. How can I pass RecId from Args?

  • Houda Chkoundali Profile Picture
    Houda Chkoundali 145 on at
    RE: Error in prePromptModifyContract() Controller Method

    In my case, the report is generated directly from a menuitem So no need to use this code? if true, so the message error persists again and I can't found solution

    Thnx

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Error in prePromptModifyContract() Controller Method

    That solution is for using the report from a form, and you would override the clicked method of a form menuitem button control.

  • Houda Chkoundali Profile Picture
    Houda Chkoundali 145 on at
    RE: Error in prePromptModifyContract() Controller Method

    Thank You Vilmos. Actually I dont understand where I place the code

    "Args args = new Args();

    args.record(BHSDataTable);

    new MenuFunction(menuitemOutputStr(BHSMenuItem), MenuItemType::Output).run(args);

    "

    It mentionned on the clicked() method of the button you will use to run your reportbut I dont know where :(

    Thnx

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Error in prePromptModifyContract() Controller Method

    Here is a great example on how to do this. You are missing a couple of steps most likely where you pre-load the contract with arguments, and also you have to override the clicked method on the menuitembutton on your form and pass in the arguments you need:

    www.bhsolutions.com/.../how-to-launch-an-ssrs-report-from-ax-with-pre-loaded-parameters

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Error in prePromptModifyContract() Controller Method

    Create one parm method() in contract class for recId. Override method prePromptModifyContract() of Controller class and pass the recId from args.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans