Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

ConfirmHandler for non Test Codeunit

Posted on by 372

Hello,

Is there a way to Handle UI through code in non Test? If the window pops up Ship, Invoice, Ship & Invoice pops up when I run the post codeunit, I want that to be preselected.

Ultimately trying to do a batch post sales based on data in a separate table, but im only extension based. 

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: ConfirmHandler for non Test Codeunit

    Not sure how that would work as I cannot edit the base objects to add in the publisher event. I only have extension based.

  • Suggested answer
    Avinash B Profile Picture
    Avinash B 1,455 on at
    RE: ConfirmHandler for non Test Codeunit

    I have 2 suggestions:

    1. You can assign SalesHeader.Ship = True or SalesHeader.invoice = True or both and call the CU 80

    2. You can still use the same event mentioned above. But set the Codeunit property EventSubscriberInstance = Manual. Then you should Binding to run the event which you have created. This will not disturb the standard feature, it will trigger the event only when you bind.

    Refer this

    docs.microsoft.com/.../devenv-eventsubscriberinstance-property

    Regards,

    Avinash B

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: ConfirmHandler for non Test Codeunit

    It would be part of my own customization. Basically I build an XMLPort to bring in orders for them staged, then syncs the sales orders, then they want to batch post the related orders, but dont want the message popping up. Cause they also want this functionality else where. Like "Ship" on sales order. To just ship the related lines etc.

  • Suggested answer
    Avinash B Profile Picture
    Avinash B 1,455 on at
    RE: ConfirmHandler for non Test Codeunit

    Do you want to do it on standard actions like the Post button on the Sales Order page OR you are building it over your customization?

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: ConfirmHandler for non Test Codeunit

    Good Morning,

    Not sure how you would do that for a specific button? In other words, if I subscribe to that codeunit, I can of course edit the parameters, but I only want this customization to take effect in times that i specify. Like a specific action on a page, or when a specific codeunit I make calls sales post.

    [EventSubscriber(ObjectType::Codeunit,Codeunit::"Sales-Post (Yes/No)",'OnBeforeConfirmSalesPost','',true,true)]
    Also - the only parameter besides Sales Header is HideDialog. I want to chose Post Ship or Invoice through the code.

    Thanks,

  • Suggested answer
    Avinash B Profile Picture
    Avinash B 1,455 on at
    RE: ConfirmHandler for non Test Codeunit

    Check if you can make use of events for this purpose. For example, in your case, you can call event OnBeforeConfirmSalesPost from codeunit 81 Sales-Post (Yes/No). You can invoke these events and it has DefaultOption parameter. you can set 1 for ship, 2 for invoice and 3 for ship & invoice. Another parameter in this event is HideDialog. you can set HideDialog to true so that you won't get the confirmation dialog while posting.

  • ChazKimRP Profile Picture
    ChazKimRP 372 on at
    RE: ConfirmHandler for non Test Codeunit

    Hello,

    Thank you for your response, but this will not work. I do not have access to base objects, strictly extension based. Also wouldnt know how that could handle a CONFIRM() or STRMENU() function.

  • Suggested answer
    Avinash B Profile Picture
    Avinash B 1,455 on at
    RE: ConfirmHandler for non Test Codeunit

    Hi

    Which version of Navision are you using?

    If your using 2016 and above versions, you have events. Using the events you can build small logic make selectable any of these options automatically based on your conditions.

    Reference:

    docs.microsoft.com/.../introducing-events

    Regards

    Avinash B

  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: ConfirmHandler for non Test Codeunit

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans