In a table I have stored a number of actions together with a corresponding function.
When I choose an action I would like to execute the function from the table instead of hardcoded execution of a function.
- Create a buffer table with all possible parameters as fields. You can add fields as the function set grows.
- For every function, create a codeunit which uses the buffer table on the OnRun trigger.
From your call table, call the respective Codeunit by number:
codeunit.run(<CodeunitNumber>,<BufferRec>)
Since the OnRun Trigger takes the record as VAR, you can pass results this way, too.
That is not possible, and honestly I don't know why you would do it in NAV. It definitely has it's uses in other languages, but why do you need to do it? IF and CASE statements should solve the issue just fine. Function names are meant to be hard coded.
Comments
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
When I choose an action I would like to execute the function from the table instead of hardcoded execution of a function.
Another option is to use id numbers of codeunits and call CODEUNI.RUN(Number)
AFAIK, no. What you can do is following:
- Create a buffer table with all possible parameters as fields. You can add fields as the function set grows.
- For every function, create a codeunit which uses the buffer table on the OnRun trigger.
From your call table, call the respective Codeunit by number:
codeunit.run(<CodeunitNumber>,<BufferRec>)
Since the OnRun Trigger takes the record as VAR, you can pass results this way, too.
with best regards
Jens