Run codeunit with -consolemode, how to pass parameters?

primeap
Member Posts: 37
Id like to execute a specific function instead of CODEUNIT.RUN. Is this possible?
0
Best Answer
-
No, not possible.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035
Answers
-
As I understand I probably want to be able to call a function on a codeunit defined at a run time, CODEUNIT.RUN(number_coming_from_some_setup_table), without declaring the actual codeunit as a variable?)
In NAV 2016+ you can get similar functionality using events. In calling code define publisher function, and call that function (instead of CODEUNIT.RUN), and in called codeunit define a subscriber subscribing to the publisher function in calling codeunit.
You would probably need some extra logic to ensure that only one subscriber executes desired code (manual binding or smth)
In older versions (without events) it is not possible.
You could try to mimic the behavior by calling the CODEUNIT.RUN on a record, and depending on the values passes call different functions, but at the end of it you wll require a place where called codeunit is defined as a variable anyway - so you would have to know its details at design time.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
No i mean from the cmd shell with Flag -consolemode0
-
No, not possible.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-035 -
That way it is not possible. But you can declare your codeunit as a webservice and then you can call functions in that codeunit using PoSh https://mibuso.com/howtos/how-to-use-powershell-to-test-your-nav-webserviceRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions