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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

XppComipler and runBuf do not work in AX7

(0) ShareShare
ReportReport
Posted on by 85

I want to upgrade an Ax2012 function to AX7. The general function like as below,
1.A form where can specify X++ code
For example,
real abc(SalesLine _salesLine)
{
   real ret;
   ret = _salesLine.LineAmount * 3;
   //x++ code....
   return ret;
}

2.Run the specified code in run-time using the XppComplier.
Below is the code sample
static void Job123(Args _args)
{
    XppCompiler compiler;
    Salesline salesline;
    real ret;

    select firstonly salesline
    compiler = new XppCompiler();
    str runCode;// X++ specified in step 1 )
    
    if (compiler.compile(runCode)
    {
       ret = compiler. execute(salesline);
       info (strfmt("%1", ret));
    }
}

I run the function in AX7, but compiler.compile(runCode) is always return ‘false’  and  compiler.execute(Salesline) is always return 0. I also try to use runBuf(runCode, salesline), it is always return ‘0’ too.

Can anyone give me a general idea on  how to upgrade the function from AX2012 to AX7?

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    303,756 Super User 2026 Season 1 on at

    What was the requirement at all to create x++ logic on runtime? Can you tell the full business requirement here? Then I might be able to understand what you want to achieve from a functional perspective.

  • Suggested answer
    Rudi Hansen Profile Picture
    4,079 on at

    Andre forgot to mention that the reason he asks is that all run-time compiling will not work in AX7.
    So that why you are having problems with your code, the functions you are calling simply do not work in AX7.

  • Sukrut Parab Profile Picture
    71,735 Moderator on at

    I am not sure about your requirement and why you want to  compile  specific code but  in D365 you  build  either project/Solution , packages etc. not individual elements.  Also although XppCompiler class is still present in the application its not used anywhere and I don't think you can use it to compile run time in D365

  • André Arnaud de Calavon Profile Picture
    303,756 Super User 2026 Season 1 on at

    @Rudi: I didn't forget to mention it; I assumed Fred already found out and had read the documentation.

  • Fred Xu Profile Picture
    85 on at

    Hi Andre,

    End user needs to be able to define the formulas for a calculattion.  i.e. fieldA + fieldB*10% + fieldC, ..., and the formulas may include X++ code logic. the system will convert the formulas into X++ code, and call XppCompiler. execute() to run the user-define formulas on runtime. This functional is work well in AX2012, now we want to upgrade it to AX7.

    Do you have any idea about how to run the user-define formulas to calculate a result in AX7?

    Thanks indvance!

    Fred

  • Muhammad Uzair Shah Profile Picture
    201 on at

    Is this issue resolved? 

    Thanks,

    Uzair

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    It depends on what you mean by "this issue". If that XppCompiler doesn't work, there won't be any fix because it's by design.

    If you explain your particular business scenario, we might be able to help you to come up with a design which is achievable in AX 7. Maybe you can use expression builder. Maybe you require X++ and therefore you should follow the same development and deployment story as with any other code. Maybe you should design your own domain-specific language and write an interpreter for it. Maybe you can use an existing one. And so on...

  • Muhammad Uzair Shah Profile Picture
    201 on at

    Dear Martin,

    What i meant was that i am using X++ code for the expressions and for that i need to compile the code using XppCompiler. There is x++ code which returns certain values based on the queries and i am using this return value for the formula calculations.

  • Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

    As you can see in the list of Deprecated APIs in Finance and Operations, XppCompiler isn't available anymore and there the answer to your request "i need to compile the code using XppCompiler" is that you simply can't do that. You'll have to look for another design, one that doesn't depend on something that doesn't exist.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Joris dG Profile Picture

Joris dG 5

#2
Andrew Jones a1x Profile Picture

Andrew Jones a1x 2

#3
GL-01081504-0 Profile Picture

GL-01081504-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans