web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

How do I cancel the ongoing action with a OnBeforeAction in AL for dynamics NAV?

(0) ShareShare
ReportReport
Posted on by 450

So I am coding in AL-language to modify the working of MS dynamics BC. Now what I am trying to achieve is the following:

By default in a Sales Quote, when you press "Make Order" a dialog appears with the question if you're sure you want to convert your quote to an order.

Now I made my own dialog with a more specific statement that I call with the following statement: OnBeforeAction. Now when I press Yes, I want to convert the Quote to an Order. If I press No I obviously want to cancel the converting process.

At the moment I manage to let the dialog pop up but whatever option I take after I select the option the default dialog pops up to ask me if I am sure i want to make the conversion from Quote to Order.

So in short: I want to overrule the existing dialog so it doesn't pop up anymore with either select Yes or No option but it needs to continue the same functionality as the default dialog box has that pops up.

Thanks in advance

*This post is locked for comments

I have the same question (0)
  • imkarthikeyan Profile Picture
    67 on at
    RE: How do I cancel the ongoing action with a OnBeforeAction in AL for dynamics NAV?

    Hi,

    I think u can use the default publisher to control the default popup dialog based on the conditions u can hide using handle boolean.

  • Verified answer
    Suresh Kulla Profile Picture
    49,918 Super User 2025 Season 2 on at
    RE: How do I cancel the ongoing action with a OnBeforeAction in AL for dynamics NAV?

    As I have mentioned, if you want to stop processing add Error('').

  • InsertX Profile Picture
    450 on at
    RE: How do I cancel the ongoing action with a OnBeforeAction in AL for dynamics NAV?

    Ok I see. Now if i wanted to keep it more simple by showing both dialogs with mine first. Is there a way to stop the default dialog from showing when i click no and to continue to the default dialog box when i click yes?

  • Verified answer
    Teddy Herryanto (That NAV Guy) Profile Picture
    14,144 Super User 2025 Season 2 on at
    RE: How do I cancel the ongoing action with a OnBeforeAction in AL for dynamics NAV?

    You can't do it that way. There is no way to skip the dialog box.

    I would suggest copy the whole function and plug it to OnBeforeRun. And do your coding there.

    Something like this :

    OnBeforeRun(VAR SalesHeader : Record "Sales Header";VAR IsHandled : Boolean)

    IsHandled := TRUE; //to make sure that the original function does not run

    TESTFIELD("Document Type","Document Type"::Quote);

    IF GUIALLOWED THEN

     IF NOT CONFIRM(ThisIsYourNewConfirmationMessage,FALSE) THEN //New confirmation message

       EXIT;

    IF CheckCustomerCreated(TRUE) THEN

     GET("Document Type"::Quote,"No.")

    ELSE

     EXIT;

    SalesQuoteToOrder.RUN(Rec);

    SalesQuoteToOrder.GetSalesOrderHeader(SalesHeader2);

    COMMIT;

    OnAfterSalesQuoteToOrderRun(SalesHeader2);

    IF GUIALLOWED THEN

     IF OfficeMgt.AttachAvailable THEN

       OpenPage := TRUE

     ELSE

       OpenPage := CONFIRM(STRSUBSTNO(OpenNewInvoiceQst,SalesHeader2."No."),TRUE);

    IF OpenPage THEN BEGIN

     CLEAR(SalesOrder);

     SalesOrder.CheckNotificationsOnce;

     SalesHeader2.SETRECFILTER;

     SalesOrder.SETTABLEVIEW(SalesHeader2);

     SalesOrder.RUN;

    END;

  • Suggested answer
    Suresh Kulla Profile Picture
    49,918 Super User 2025 Season 2 on at
    RE: How do I cancel the ongoing action with a OnBeforeAction in AL for dynamics NAV?

    Try adding the commit after your custom code and then add the Error('') statement so that it will stop executing the rest of the 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#2
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans