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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Get SSRS Report Parameter Value from Form

(1) ShareShare
ReportReport
Posted on by

Hi Experts,

Im facing problem about getting value ssrs parameter from the caller form.

Here is the custom form :

form1.png

In the red box are the parameters to filter data to table. The report I made need to print all the result data from filtering.
Here is my report parameter :

form2.png

I need to get value from the field in the caller form to my report parameter. I just can show the value of As On Date from the filtering because that was the only field that contain in the data source grid.

Below is my controller code :

protected void prePromptModifyContract()
{
   args             xArgs;

   super();

   xArgs = this.parmArgs();

   contract = this.parmReportContract().parmRdpContract();
   contract.parmasondate(Args.record().(fieldNum(FCardTable, AsOnDate)));

}


form3.png

Has anyone have solution for this?
Im using UIBuilder in the report.

Im very grateful if any of you can help my problem .

Thanks and Regards

Enggar

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Zain Bokhari Profile Picture
    3,208 Moderator on at

    Hi Enggar,

    I faced it a year back and there was no proper solution for it. You will not find an easy answer for this one.

    If there was just one or two parameters you could've passed them on to controller class easily from where you could pass them on to contract class in the prePromtModify method like you're already doing.

    One way is to create the same fields as needed in parameters in the datasource of your form which will make it easy for you and you will be able to pass the parameters same as the AsOnDate parameter. (Not recommended).

    Solution:

    The workaround I had to develop for achieving this is a bit complex but it works. What you can do is concatenate all the parameters in a string and pass that string as a parameter to the report controller. Then in the prePromptModifyContract method you can tokenize/break the string, get your parameters and assign them to your contract class.

    Here,

    Override the click method of the button which runs your report and add code like this.

    void clicked()
    {

    Args args = new Args();

    str parameterString;
    ;

    args.record(FCardTable);

    args.caller(this);

    // add parameters to a single string

    parameterString += strfmt("%1,%2,%3,%4",fromDate.valueStr(),toDate.valueStr(),site.valueStr(),warehouse.valueStr());
    args.parm(parameterString); //change the fields as per your own code

    //Assuming you have created these fields just on the form and auto declaration for them is set to "yes".
    new MenuFunction(menuItemOutputStr(yourReportControllerMenuItemName), MenuItemType::Output).run(args);

    }

     

    Now in the controller class of your report do something like this.

    protected void prePromptModifyContract()
    {

    args xArgs;
    container conParm;
    TransDate fromDate, toDate;
    str siteID, wareHouse;

    super();

    xArgs = this.parmArgs();

    conParm = str2Con(this.parmArgs().parm()); //this will give you parameters from the string we created
    fromDate = str2Date( conpeek(conParm,1), 213);

    //second parameter is the date sequence fro day month year, you can change it per your requirement

    //1 = day, 2= month, 3 =year
    toDate = str2Date( conpeek(conParm,2), 213);
    siteID = conpeek(conParm,3);
    wareHouse= conpeek(conParm,4);

    contract = this.parmReportContract().parmRdpContract();
    contract.parmasondate(Args.record().(fieldNum(FCardTable, AsOnDate)));

    contract.parmfromdate(fromDate);
    contract.parmfromdate(toDate);
    contract.parmfromdate(siteID);
    contract.parmfromdate(wareHouse);

    }

     

    Please try this and let me know if you have any issues.

    Mark the answer verified if this solves your problem.

  • Community Member Profile Picture
    on at

    Hi Zain Bokhari,

    Thanks for your reply, it mean a lot to me.
    I'll try your solution and inform you the result.
    Thank you very much

    Regards,

    Enggar

  • Community Member Profile Picture
    on at

    Hi,

            Instead of doing code, Why don't you use query ranges for your AsOnDate using query?

    Thanks

    Suresh

  • Community Member Profile Picture
    on at

    Hi Zain Bokhari,

    Your suggestion made my day, it works perfectly.
    Thank you very much.
    So if there are other parameter in the form I need to adding in the controller class right?

    Thanks and Regards,

    Enggar

  • Community Member Profile Picture
    on at

    Hi Suresh,

    Thanks for your reply, it mean a lot to me.

    But Zain suggestion is working perfectly in my case

    Thank you very much.

    Regards,

    Enggar

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    You're welcome Enggar.

    Well if the parameter you want to add is a form level field (Not a field on your form's data-sources) then you will have to do exactly what we did with the previous parameters. I mean add another value in the string and receive it in the controller class with others.

    I am glad I could help.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans