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)

Can't call static AX Method from SSRS Data method

(0) ShareShare
ReportReport
Posted on by

Hi all,

i use AX 2012.

In this https://msdn.microsoft.com/en-us/library/cc622853(v=ax.50).aspx you can read how easily you can call a X++ method.

But here is the Problem. Here is my test method:

[DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    public static string getDateFormat(string date)
    {
        AxaptaWrapper axapta = SessionManager.GetSession();
        return date + " ja";
    }


Here i became a warning: "The SessionManager.GetSession method is obsolete. The ability to use Business Connector .NET from report data methods will be removed in a future version of Microsoft Dynamics AX."

The result of this is that i can use the method in the report, but everywhere i use this i get "#error" in runtime. When i commit out this line, no error is shown.

The other opportunity is to use this:

 [DataMethod(), PermissionSet(SecurityAction.Assert, Name = "FullTrust")]
    public static string getDateFormat(string date)
    {
        AxaptaWrapper axapta = SessionManager.CreateSession();
        return date + " ja";
    }


But here the compiler shows an error: "'Microsoft.Dynamics.Framework.Reports.SessionManager.CreateSession()' is inaccessible due to its protection level"

So what I have to do in AX 2012 to call a static AX method?

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    What's that crucial that you want to call it in this way, despite the fact that you'll have to throw it away and start again, as soon as you want to upgrade your solution? It would be much more efficient to do use a supported solution straight away, wouldn't it?

  • Community Member Profile Picture
    on at

    Please tell me a supported solution.

    I want to open a PDF File from a Report.

    In the Report i have the Documentnumber and in AX i have a method, which download the PDF to the local machine and gives back the path of it.

    Now my goal have to be to call the method from SSRS with the documentNo as parameter.

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    What do you mean by opening from a report?

    If you want to print a report and then show a PDF file, simply do it in your report controller class in AX?

    Or do you want to embed the PDF file as an integral part of your report?

    What do you mean by "the local machine"?

  • Community Member Profile Picture
    on at

    The user see some Invoices, behind every Invoice is a Image which shows a pdf logo. If the user clicks on the image, the pdf file should open.

    This is realized over image Properties -> Action -> Goto URL -> Expression:

    ="javascript:void(window.open('file://AX2012R2A/Share/test.pdf'))"

    But this is a fixed file, i have to insert the path of the invoice.

    I get the path of the invoice with a DocumentNo. which comes from the db.

    But i need the AX Method to locate the pdf file and than i can write in my Expression:

    ="javascript:void(window.open('file:" & getPath(documentNo) & "'))"

    this is my goal, but it didn't work because in the getPath (above it calls getDateFormat) method i can't call my AX method

  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    I think the best solution for this requirement is using a drill through action.

  • Community Member Profile Picture
    on at

    i will check it and post my result

  • Suggested answer
    AXT Profile Picture
    1,699 on at

    James,

    Since this feature is marked as deprecated, i couldn't find any hint what's the new standard way of doing this is, but another blog brought me to the right(?) direction. In the SSRS DataMethod:

    SC2.jpg

    SC2.jpg

    You have to add a reference to the Library "Microsoft.Dynamics.BusinessConnectorNet" that is located in C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\bin\

  • Community Member Profile Picture
    on at

    Hi AXT,

    thank you for your answer!

    I couldn't found any solution too, so i hope your answer will help!

    I will try it tomorrow or next week and post my result!

    Thank you so much !

  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    This goes back to Martin's first reply which refers to using functions which are deprecated in the newer versions, namely Business Connector. Refer to AxBC here:

    ax.help.dynamics.com/.../deprecated-features-in-dynamics-ax-7

    Why don't you just have an additional field in the tmp table passed in with the data contract, referring to your PDF document/identifier, and set that as the value for the URI?

  • Community Member Profile Picture
    on at

    Hi, 

    i had no time to test your answer!

    We also built a different interface, so the problem is no longer present.

    BG James

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