Skip to main content

Notifications

Business Central forum
Answered

Putting values in a table on executing custom action

Posted on by 382

Hello community, 

I have created a custom action button ("Post WHT") on a custom page ("WHT Transaction"). Now I want that whenever the action is executed all the values currently present on the custom page should be appended to the payment journal new line.  Below pictures will clear this more.  In the first image, the custom action and custom page is shown and in the second image payment journal lines are shown. Now whenever I execute the action, the values from my custom page should be appended to the new line of payment journal. I tried posting this but I am getting primary key error in shown in third image. There is no primary key used in the custom table or page. Kindly help.

pastedimage1672039056746v1.png

pastedimage1672039217999v2.png

pastedimage1672039999643v3.png

Categories:
  • RE: Putting values in a table on executing custom action

    It worked for me. Thanks to both of you Mohana and Pankaj. Your efforts are highly appreciated specially Pankaj. Thank you once again.  

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 58,874 Super User 2024 Season 2 on at
    RE: Putting values in a table on executing custom action

    You have to use Rec_payment_journal .Insert and not Modify.

  • Suggested answer
    pankaj.k Profile Picture
    pankaj.k 960 on at
    RE: Putting values in a table on executing custom action

    you need to user debugger that will help you more of share your full code and error detail

  • RE: Putting values in a table on executing custom action

    It is done. Thank you. but I'm getting the error below. Although I have inspected the payment journal page and the first line no. is 10000 so the second should be 20000 but still I'm getting error.

    pastedimage1672127022248v1.png

    pastedimage1672127122764v2.png

  • Suggested answer
    pankaj.k Profile Picture
    pankaj.k 960 on at
    RE: Putting values in a table on executing custom action

    use your table name befor the function 


    Rec_payment_journal 

  • RE: Putting values in a table on executing custom action

    pastedimage1672126378806v1.png

  • pankaj.k Profile Picture
    pankaj.k 960 on at
    RE: Putting values in a table on executing custom action

    Show your code.

  • RE: Putting values in a table on executing custom action

    But Pankaj GetNewLineNo is not a built-in method. So I am getting an error when using this.

  • Verified answer
    pankaj.k Profile Picture
    pankaj.k 960 on at
    RE: Putting values in a table on executing custom action

    Use the below function that will help to increase the line number.

    LineNo := GenJnLine.GetNewLineNo(SRSetup.LoanAutoPstTemplate, SRSetup.LoanAutoPstBatch);
    GenJnLine."Line No." := LineNo;
    for check the line No.  on the page of Gen Jour.. open the Page Inspection  use the shortcut key  CTRL + ALT + F1 

    zzz3.PNG

  • RE: Putting values in a table on executing custom action

    Hi Mohana, GetNewLineNo is a user-defined method maybe. Can you give me the source code?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans