Optional Parameters

Magno
Member Posts: 168
Hi,
Is it possible to write a function with optional parameters?
Grtz
Is it possible to write a function with optional parameters?
Grtz
0
Comments
-
Nope, no such thing as optional parameters in C/AL. You add a parameter to a function, you have to find all references to it and change them.
You could create a new function with the additional parameter and add a call to the new one in the old one with a default value for the new parameter.0 -
Or use a codeunit that is single-instance. Put the optional parameters in it and then call your function.
Or add 1 parameter as text 1024 and put in it all your optional parameters as textRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Create a new table, each field in the table will act as a parameter.
Make this table the only parameter in the function.
Fill the table, then call the function, if you define it as temporary in both places (in the code and as a parameter) you wont need it to be in the license.
If you need to add more parameters then just add more fields to the table.
-a0 -
Or to save a table, use an existing table.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
If you declare the table as temporary in both places you won't be wasting a table in the license.
I'd rather do that than add fields to a table, which will be blank all the time, but still potentially take up space in the database with all of the other records in the table. A temporary table never holds data on the server so no space will be taken up in the database.
For example, if you add 10 decimal fields to the item ledger entry you make that table bigger for all the records that are in there - if you like the structure of that table so much just make a copy of it outside the license and keep it declared as temporary everywhere you declare it in code.
-a0 -
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