Select a certain function

einsTeIn.NET
Member Posts: 1,050
Is there any dodge to create a setup where you can choose a certain function?
I know you can use
I know you can use
CODEUNIT.RUN(SetupTable."Codeunit No.",Rec)but I have many, many setup records and I don't want to create as many codeunits. And no one wants to pay for such many codeunits.
"Money is likewise the greatest chance and the greatest scourge of mankind."
0
Comments
-
only an idea. Do you checkt RecRef :?:
One CU -> Parameter is RecRef .....Do you make it right, it works too!0 -
garak wrote:only an idea. Do you checkt RecRef :?:
One CU -> Parameter is RecRef .....
Not possible with RecordRef .. I mean not possible to have codeunit with RecordRef as a parameter. Codeunits accept only records as a parameters - you can set only TableNo property.
That would be very nice feature....
As a workaround you may create new table to use it as some kind of 'code redirector', but hard-coding function names would e necessary at the end..
Or create a function inside codeunit with RecordRef as a parameter, but then CODEUNIT.RUN(number, RecRef) is not possible, rather CodeunitVariable.SomeSetupFunction(RecordRef)
Regards,
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
i know, that it is not possible to create a CU with parameter RecRef.
What i mean is a CU with a function and this function has RecRef as parameter .....Do you make it right, it works too!0 -
oh, i seeOne CU -> Parameter is RecRef .....
One CU -> New Function -> Parameter is RecRef ....
So, its true, nobody can understand me
8-[Do you make it right, it works too!0 -
Hmmm, I don't know if it's clear what I mean. :?:
I don't want to run a codeunit with RecRef. I try to give an example...
Table 50000 Data
Field 1|Category|Value
12345|A_______|15
12341|B_______|28
Table Setup
Category|CU No.
A______|50000
B______|50001
C______|50002
CU 50000 with TableNo 50000 (Rec Data)
OnRun()Value := Value * 5; MODIFY;
CU 50001 with TableNo 50000 (Rec Data)
OnRun()Value := Value * 12 - 14; MODIFY;
CU 50002 with TableNo 50000 (Rec Data)
OnRun()Value := (Value + 17) / 3; MODIFY;
I want to create a solution where the user could specifiy which calulation the system should take on a certain category. (The calculation is more complax than this example, it's just to make it clear.)
Now my problem is that I (or the user) have to create as many codeunits as different setup records are given. It would be better if the user could specify "Function No." instead of "Codeunit No.". The solution would need less codeunits and the license wouldn't need to be updated every time a new calculation would be added."Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Why don't you write some math engine to parse and execute math formulas? Then you can store many different calculation formulas. It should be easy especially if there are constant number of record types and fileds you need to play with.
Here is some example: http://www.mibuso.com/dlinfo.asp?FileID=820
Hope this helps.
Regards,
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
It's not only about math formula calculation. It was only an example. There could be also codeunits that do other things, e.g.
CU 50003 with TableNo 50000 (Rec Data)
OnRun()CLEAR(LedgEntry); LedgEntry.LOCKTABLE; LedgEntry.FINDLAST; LedgEntry."Entry No." += 1; LedgEntry."Posting Date" := TODAY; LedgEntry.Category := Category; LedgEntry.Value := Value; LedgEntry.INSERT;
"Money is likewise the greatest chance and the greatest scourge of mankind."0 -
Hi
Maybe another idea
Create a codeunit and one specific function which accepts recref and tabled id
call this function from your object and in this function have a case statement calling the specific other functionsSetupFunction(RecRef,TableID) CASE TabledID OF DATABASE::"Sales Line" : BEGIN CallSalesFunc(RecRef); END; . . . END:
Albert0 -
Maybe I am thinking about this too simply.
Add a new field to the record, called FunctionNumber.
Set the field before passing the record into the codeunit.
YourTable.FunctionNumber = 4;
YourTable.MODIFY;
CODEUNIT.RUN(50000,YourTable);
//In codeunit 50000
OnRun
CASE YourTable.FunctionNumber of
1: PostLine;
2: CheckLine;
3: CalculateSquareRoot;
4: Function4;
5: Function5;
END;
?0 -
Yeah, somebody who understands me!
I've had the same idea, but the problem is that the user will have to know which No. will execute which function. I thought of something that is more self-explanatory. E.g. if the user could see the name of the functions (MultiplyValueBy4, PostLine, GetAssignedEmployee,...) or anything else that would help to fill the setup table correctly."Money is likewise the greatest chance and the greatest scourge of mankind."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