Header Ads Widget

How to Execute a Runnable Class Using a URL in D365FO || X++

 

🧠 Overview

In Dynamics 365 Finance and Operations (D365FO), a Runnable class (also known as a job) is an X++ class with a main method that can be executed independently. While developers often run these classes from Visual Studio or via a menu item, you can also trigger them directly via a browser URL — which is especially useful in testing, automation, or debugging environments.

This post explains how to run a Runnable class using a URL, the parameters involved, and best practices to follow.


🚀 Methods to Run a Runnable Class

There are three main ways to execute a Runnable class in D365FO:

  1. Using a Menu Item

    • Create a menu item referencing the class.

    • Add it to a form or workspace and launch it from the UI.

  2. Using Visual Studio

    • Set the class as the Startup Object and run it with debug support.

  3. Using a Web Browser URL

    • Run the class directly by composing a special URL.


🔗 Format of the URL

plaintext
https://<your-d365fo-environment>/?cmp=<company>&mi=SysClassRunner&cls=<RunnableClassName>

✅ Parameter Breakdown

ParameterDescription
your-d365fo-environmentThe full base URL of your D365FO environment (e.g., https://usnconeboxax1aos.cloud.onebox.dynamics.com)
cmpThe legal entity (company code) where you want to execute the class (e.g., USMF)
miSet to SysClassRunner (required to launch X++ classes from the URL)
clsThe name of your Runnable class (e.g., SalesOrderCounter)

🌐 Full Example URL

plaintext
https://usnconeboxax1aos.cloud.onebox.dynamics.com/?cmp=USMF&mi=SysClassRunner&cls=SalesOrderCounter

When you paste this into your browser (and you're logged into the environment), the class will execute immediately — assuming it has no UI and handles all logic in the main() method.


🛡️ Best Practices

  • Ensure the class extends RunBase or uses a valid main() method structure.

  • Keep the class side-effect safe (no unintended updates unless needed).

  • Always test in a sandbox before trying this in a production instance.

  • Consider adding a confirmation prompt or logging if the class performs any critical updates.


📌 Bonus Tip: Create a Static Bookmark

For classes you run frequently (e.g., cache clearing, data sync), you can bookmark the execution URL for quick access.


✅ Example Runnable Class (Minimal)

x++
class SalesOrderCounter { public static void main(Args _args) { int total = SalesTable::findAll().recordCount(); info(strFmt("Total Sales Orders: %1", total)); } }

📚 Conclusion

Using the browser-based URL execution method is a quick and efficient way to run Runnable classes in D365FO. It eliminates the need to compile/run from Visual Studio or navigate through menu items. Just build the URL, log in, and run your code instantly.

Post a Comment

0 Comments