Use Acumatica xRP Platform from Console App

Hi All,


Did you know that it is not necessary to have a Web Site under IIS to get benefits from Acumatica Platform?

You actually can run Acumatica platform even from console app!

To do this you just simple do following:

  1. Create Console Application in Visual Studio
  2. Add references to (PX.Common.dll, PX.Data.dll, PX.Objects.dll)
  3. Copy web.config from Acumatica site to app.config of your console application
  4. Specify user and company using PXLoginScope
  5. Use Acumatica Platform as normally you do that.

Here you can find a code example followed by some comments:

namespace AcumaticaConsole
	class Program
		static void Main(string[] args)
			using (new PXLoginScope("admin@Demo"))
				PXGraph graph = PXGraph.CreateInstance<PXGraph>();

				foreach (Account row in PXSelect<Account>.Select(graph))
					Console.WriteLine(row.AccountCD + " - " + row.Description);

App.config file is required to Acumatica platform to get proper environment configurations, database connection and other settings. For experiments you can just take whole file and replace it, so you don’t need to make a manual merge. If you use your own configurations in App.config, than you need to merge your configurations with Acumatica
configurations. Please try to avoid to use same names or settings as Acumatica uses as it may affect Acumatica execution.

Acumatica App Config

PXLoginScope is required to identify user and company that should be used for database selects. PXLoginScope is scope type class and will be effective only for nested code, so as soon as you leave the scope block user is logged out.
Please also note that login is filled with the following format “username@company”. Acumatica will automatically parse it and extract user and company for internal login.
Password is not required here as the login done from code. Alternatively you can login user using PXLogin class, where password will be checked.

Now you can use your Favorite BQL even from Console App 🙂 Or write a fast testing program without screen or interface!

Acumatica Console App

Hope it helps and have fun!

1 Reply to “Use Acumatica xRP Platform from Console App”

  1. Awesome, these posts that open up possibilities of automation of managing my small collection of instances are my favorite.

    Thanks Sergey, this blog is overflowing with really amazing information

Leave a Reply

Your email address will not be published. Required fields are marked *