Print this Post

Start NAV Object in RTC with PowerShell

You might remember these blogposts:

I wanted to go a step further. Namely, I wanted to open/run a specific object from PowerShell.


There are two scenario’s where I wanted to apply this:

  1. First of all the Test Toolkit. I’m sure we’re all using the testability framework, right? ;-). Well, automation of this framework makes sense. Automation with PowerShell makes sense as well. And running the Test codeunits with the CmdLet “Invoke-NAVCodeunit” is just not done, because the testability (and especially the test pages) needs to run in an environment WITH a User Interface. Invoke-NAVCodeunit is a background process, therefore not suitable to run Tests of the Testability framework. So I want to run a codeunit (For example the Test Runner) like I would do a Run of a codeunit in C/SIDE.
  2. In a demo scenario, I usually import objects and run a codeunit to import data into tables. I wanted to automate all: import objects, run codeunit AND show the data in the table that I just created. In this case, I wanted to run a table like I would run it in C/SIDE.

In other words, I would like to create a function like:


That says it all, doesn’t it? 🙂 I didn’t care too much on mandatory parameters and such .. but I tried to create a function that also works in a Multitenant environment. Here is how it looks:

There are only a few tricks that I would like to mention:

  • In my parameters, I’m using the “ValidateSet” attribute to provide a predefined set of values for “ObjectType” variable – which makes a lot of sense, obviously 😉
  • I couldn’t find anywhere how to provide both tenant and objectid in the URL. I checked MSDN and tried to search online, but nowhere. The problem is, you can provide the tenant with a “?” in the URL, like:

    DynamicsNAV://WIN-K5JLU49T31O:7046/DynamicsNAV90/CRONUS BELGIË NV/?tenant=default

    You can run a codeunit by also using that questionmark, like:

    DynamicsNAV://WIN-K5JLU49T31O:7046/DynamicsNAV90/CRONUS BELGIË NV/RunCodeunit?Codeunit=50000

    But how to combine the two? How to run a codeunit in a company of a specific tenant?? Apparently, the solution was quite simple: it’s just a matter of combining the two with an ampersand (&), like:

    DynamicsNAV://WIN-K5JLU49T31O:7046/DynamicsNAV90/CRONUS BELGIË NV/RunCodeunit?Codeunit=50000&tenant=default

Here are a few examples on how you can run the function.

Or with tenant:


5.00 avg. rating (98% score) - 4 votes

Permanent link to this article: http://www.waldo.be/2015/07/09/start-nav-object-in-rtc-with-powershell/

1 comment

2 pings

  1. arvinderrehal

    Microsoft Dynamics NAV
    Comprehensive Dynamics NAV adjudication that will appreciate the way you work and augment your finance conduct. Most info, http://crmwebx.com/

  1. Dynamics NAV 2016 it is … » waldo's blog

    […] « Start NAV Object in RTC with PowerShell […]

Leave a Reply

%d bloggers like this: