How to have a codeunit with a onrun parameter

Sog
Member Posts: 1,023
When trying to add a parameter in the onrun function of a codeunit in design it is not possible.
But when it is wanted to have a parameter you can export the object in txt format,
add in the properties section just before the onrun section the parameter and import it again.
(look at "<-- this is the parameter" in the codesnippet)
So far I've only tested it with a record as a variable. The correct syntax for other datatypes is so far unkown to me.
But when it is wanted to have a parameter you can export the object in txt format,
add in the properties section just before the onrun section the parameter and import it again.
(look at "<-- this is the parameter" in the codesnippet)
So far I've only tested it with a record as a variable. The correct syntax for other datatypes is so far unkown to me.
OBJECT Codeunit 50000 test { OBJECT-PROPERTIES { Date=25/05/09; Time=[10:31:00]; Modified=No; Version List=; } PROPERTIES { TableNo=36; <- this is the parameter (in this case table sales header) OnRun=BEGIN END; }
0
Answers
-
It's not possible to add anything other than a record variable as a parameter to a codeunit. In the object designer this is done in the codeunit properties, where you select the table from the table list. There's no need to export as text and then modify the text file.0
-
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision' forum]Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
DenSter wrote:It's not possible to add anything other than a record variable as a parameter to a codeunit.
As DenSter quoted, you only can use a record as parameter. For special needs you can use one of these methods:
- Create a special record only for the parameters
- Before calling the run method calling a user defined function (called setParams for example) to set one or more global variables of the the codeunit. These globals can be used afterwords. Of course the globals will be reset if the variable of the codeunit goes out of scope.
Hope this helps
Thomas0 -
oh, and here I was thinking I discovered something that was not implemented in the designer.
I guess I've been a little bit to optimistic (or pessimistic, depends how you look at it)0 -
Sog wrote:oh, and here I was thinking I discovered something that was not implemented in the designer.
I guess I've been a little bit to optimistic (or pessimistic, depends how you look at it)
Even if you had found something that the NAV PG missed, would you really want to use an unsupported feature like this in a live environment?David Singleton0 -
Sog wrote:oh, and here I was thinking I discovered something that was not implemented in the designer.
I guess I've been a little bit to optimistic (or pessimistic, depends how you look at it)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