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)

Can you have a Button on a Form that when clicked will read X++ code in a StringText field on the same Form.

(0) ShareShare
ReportReport
Posted on by

Can you have a Button on a Form that when clicked will read X++ code in a StringText field on the same Form.  Basically if in the StringText field has info("Hello") when the button is clicked a box will pop up saying hello. This button will run the StringText like it is a Job node, just this Job node is on a form where a user with the right privileges can write in X++ code.

*This post is locked for comments

I have the same question (0)
  • 640579632b5c4e6780a624c4771b6f93 Profile Picture
    4,730 on at

     

     

     

     

    You are looking for a scripting engine. I dont think, it is good idea to run x++ code at runtime.

    you can load all the objects needed by your script into a dynamic language like ironpython or IronRuby then run the script throuhg scriptEngine. It will provide a sand box.

    Also, see public sector rate engine code for reference they have use AXproxies and allow user to write the script in C# and VB

    str

    text;

    XppCompiler compiler;

    ExecutePermission permission;

    ;

     

     

     

    permission =

     

     

    new

    ExecutePermission();

     

    // BP deviation documented

    compiler =

     

     

    new

    XppCompiler();

    text =

     

     

    strFmt('%1 test(){return new %1();}'

    compiler.compile(text);

    compiler.execute();

     

  • Michael Fruergaard Pontoppidan Profile Picture
    1,616 on at

    Take a look in the SysTableBrowser form. It is doing what you are looking for.

    Please pay close attention to security and performance when heading down this path.

    • Security: Anyone who can write X++ code will have full access to any data on the system - for a dev tool that is ok - otherwise it is not.  
    • Performance: Compiling X++ code at run time does not scale. Do not use it in scenarios where high throughput is required.
  • Peter Villadsen Profile Picture
    Microsoft Employee on at

    You can easily do what you want by using the XppCompiler kernel class. It allows you to compile and execute X++ code on the fly, with a very easy interface. However, I do not think it is a good idea to do so. You basically have no control over the kind of code the user wants to execute. But: Yes, it is easy to do.

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