call function from variable

ervaroervaro Member Posts: 17
Hi,

Is it possible to call a function from a variable.

Thanks in advance for any help.

Best regards,

Erik

Comments

  • ara3nara3n Member Posts: 9,256
    I don't think I understand your question. Could you explain what you are trying to do?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ervaroervaro Member Posts: 17
    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.
  • vaprogvaprog Member Posts: 1,139
    I think the closes you can get with CA/L is to create a CASE statement with the function name as the condition.

    Another option is to use id numbers of codeunits and call CODEUNI.RUN(Number)
  • jglathejglathe Member Posts: 639
    Hi ervaro,

    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
  • matttraxmatttrax Member Posts: 2,309
    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.
Sign In or Register to comment.