Code Unit returns value

nhelnhel Member Posts: 39
Hi Nav developers,

Is there a way how this code unit returns value, and assign it to global variable.?

Thanks.

Comments

  • jlandeenjlandeen Member Posts: 524
    If you're planning on using the Codeunit.run(<variable>) syntax then no. You cannot change the definition of the trigger (like you could in other languages).

    However you should be able to define functions for you to handle setting and retrieving values from the codeunit. This is like declaring Get and Set properties.

    However this means that you have to declare a global or local variable to represent the codeunit and you can't use the more generic CODEUNIT.RUN(<Codeunit Number>,<variable>) syntax.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • nhelnhel Member Posts: 39
    My problem is when i use function, i cannot attached the function to my button attached at the request form of the report.
  • jlandeenjlandeen Member Posts: 524
    You should be able to write some code to check the value and use these functions in the OnPush trigger of a button the request form of your report.

    What value are you trying to get back? What are you trying to do with it?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • nhelnhel Member Posts: 39
    Yes i was able to create code and get a correct return value.
    But my problem is that.

    No such Onpush trigger, if this button attached to the request form of a report for me able to call my function.

    Ill give you some background for this purpose.

    I attached a command button at the request form of the report for the user can initialized the location path where the text file tobe extracted base from the report.Because this textfile has a specific format.
  • jlandeenjlandeen Member Posts: 524
    There should be an OnPush trigger on every button control that you put on a form.

    Why are you putting any code in a codeunit....you should be able to write fucntions in your report object that handle file manipuation and parsing or generating a file name. If you did that then you wouldn't need a codeunit.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • nhelnhel Member Posts: 39
    Yes i was also wondering why theres no Onpush Trigger event to this button. I think this is because this is a request form from report not an ordinary form created at object designer.

    Another thing is that i use to create the code unit because as i notice from the property of the button.It can call a code unit at "PushAction" = RunObject so i can assign RunObject = MyCodeUnit.

    And i created a Global Function to this report, as you advice.With same procedure with my CodeUnit.

    But i cannot called the function Onpush event to that button.
    Because no such Onpush event to that button because it is attached to the request form of a report.
    ](*,)


    Thanks.
  • jlandeenjlandeen Member Posts: 524
    Yeah I just tried it on one of my reports - the trigger does show up.

    Do you have a full developers license? Or just report developer?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • nhelnhel Member Posts: 39
    Ic..i think i should ask from technical..
    Meaning you have the option of right clicking the command button and the onpush trigger show?
  • jlandeenjlandeen Member Posts: 524
    Yes it does sound like you've got a license or permission error.

    In the Request form designer you should be able to highlight the button, click F9 (or the CAL Code button on the menu bar) and see the Navision code and the OnPush trigger. If you cannot get to the CAL code then you probably don't have the license to modify that report or a report object.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • nhelnhel Member Posts: 39
    Hi jlandeen,

    I notice no option of right clicking the object command button.
    But when i press F9. I see the code and there is an event OnPUsh()
    I used to put my fuction there and it seems it really works,

    Thanks for your advice,
  • jlandeenjlandeen Member Posts: 524
    well I'm glad to hear that you got everything worked out :D
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
Sign In or Register to comment.