Code unit call from Menu Item

arindamarindam Member Posts: 176
Hi All,

I am stuck on an issue - Senario

I have written a code unit, which takes Sales header Id as input parameter. Now I want to call that code unit from Order/Invoice form. I have created a Menu Item at Order button of 'Order' form called 'Call my Code'.

Now I want to call my code unit from this menu item and need to pass Header Id as parameter. Please not, I have created a function in the code unit and I want to run that function. I dont want to call 'RUN' method of the code unit.

Please help.
Thanks in advance.

Arindam

Answers

  • AlbertvhAlbertvh Member Posts: 516
    Hi Arindam,

    you call your codeunit as follows
    CLEAR(MyCodeUnit);
    MyCodeUnit.MyFunctionName(SalesHeader,"no.");
    

    Hope this helps
  • arindamarindam Member Posts: 176
    Thanks for your reply.

    Where shall I write this code. I want to run my code unit from the menu.
    For example -
    In Order form's Order button we have a list of menus (List,Statistics etc....). Here I have created a menu item. Now I want to run my code unit on click of that particular menu.
  • AlbertvhAlbertvh Member Posts: 516
    C/AL Code in the OnPush of your menu button.

    Albert
  • arindamarindam Member Posts: 176
    Here I am not using general button. I am using Menu Button. I am not finding any OnPush event for Menu Button.
  • arindamarindam Member Posts: 176
    I have written the code at OnPush event but still it is not firing the event.
  • AlbertvhAlbertvh Member Posts: 516
    Hi Arindam,

    Go to your new Menu Item and press F9 or click View-> C/AL Code and
    you will see the OnPush and put your code there.


    Albert
  • diptish.naskardiptish.naskar Member Posts: 360
    Hi Arindam,

    Use this
    CU.FUNC("No.");
    

    where CU is the codeunit, FUNC is the function defined by you and No. is the sales header/sales document No.
    Diptish Naskar
    For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
  • arindamarindam Member Posts: 176
    Thank you Albert and Diptesh.
    Your solution solved my problem.
Sign In or Register to comment.