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)
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 .....
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."
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.
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 functions
SetupFunction(RecRef,TableID)
CASE TabledID OF
DATABASE::"Sales Line" :
BEGIN
CallSalesFunc(RecRef);
END;
.
.
.
END:
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."
Comments
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,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
What i mean is a CU with a function and this function has RecRef as parameter .....
So, its true, nobody can understand me
8-[
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() CU 50001 with TableNo 50000 (Rec Data)
OnRun() CU 50002 with TableNo 50000 (Rec Data)
OnRun()
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.
Here is some example: http://www.mibuso.com/dlinfo.asp?FileID=820
Hope this helps.
Regards,
Slawek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
CU 50003 with TableNo 50000 (Rec Data)
OnRun()
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 functions
Albert
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;
?
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.